From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: What's missing in ELisp that makes people want to use cl-lib? Date: Wed, 15 Nov 2023 00:53:09 +0000 Message-ID: References: <87il6bt4z0.fsf@yahoo.com> <8734xetjkk.fsf@yahoo.com> <87cywhsrcf.fsf@yahoo.com> <87cywgx1z0.fsf@web.de> <83wmuowwp3.fsf@gnu.org> <83leb3v5al.fsf@gnu.org> <87a5rgrbvv.fsf@neko.mail-host-address-is-not-set> <87edgsmwni.fsf@yahoo.com> <871qcskzda.fsf@neko.mail-host-address-is-not-set> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7717"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Po Lu , rms@gnu.org, Eli Zaretskii , emacs-devel@gnu.org To: Tomas Hlavaty Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Nov 15 01:54:25 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r34Ai-0001kk-9X for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Nov 2023 01:54:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r349z-0005JE-PG; Tue, 14 Nov 2023 19:53:39 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r349q-00052v-2t for emacs-devel@gnu.org; Tue, 14 Nov 2023 19:53:32 -0500 Original-Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r349l-0003Sy-Cp; Tue, 14 Nov 2023 19:53:27 -0500 Original-Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-5094cb3a036so8748476e87.2; Tue, 14 Nov 2023 16:53:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700009601; x=1700614401; darn=gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=44TBQXAZbdZuHZLJyHjFSTr7G/OjaiDXbpixtykNXdE=; b=d8UOkRYworz9HeM0yQ7IkxYGXArE//W7DYPVPa1q9lrQsBtG3ElubUUsNh/9oiPOW6 duZ4GXD/SK+CqD5Uzti3Frx+1g8d69O+rI2mwmwOdmq2ebkoRymO9eK+nO8ryYpM13tw epMr5HBgn90PShIiJhB5cK9nD6n/4ojjFZoC7xLacwDm8v3CLqAC4E5//56t/24Qt1cW xu2Hvaf7K0DpdNX/rhy6GmrJRMmy59af0QqILejGpicRcpZBqbAuoog1q2xk2eGbPgQn MvRDnAkvuuprR+8TRYxfKVoXa6QWDRRUCUk2ujWoCvM33Bx6Smht0t8dBvcvwtefZVVY ErgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700009601; x=1700614401; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=44TBQXAZbdZuHZLJyHjFSTr7G/OjaiDXbpixtykNXdE=; b=KpJcSkdvrPZ5fpaAqUA0UQRXSX+Ql7yZ27iTUvpA+mGWcCKxTfDVCspo6ul7fOIElb FyI5qxKWn9I85U10Ahxem0NFVwBYq712fl1Pg0SBVvy0YFpsl/3Mo6d8XY0cC9x2N/L3 WtUsaz/W7S72D8eWMH2EGF13K0QD+KItQh40g1VYEZAWy6ty5GltkkGh+02fcqAcF2sy JoaKV7waLWb0ahVGWw0maPsRWfflE0H6K7TjIPg4wvwW1mgdkxKeL/K0RkwOWjTx2vsE 4N5u7gH13hojO9ep3ijwhcLcyLn0m3Rg0aSC0hHgB0+2+1kQEkA1jFHVfHUXvPvrm8q2 X2pA== X-Gm-Message-State: AOJu0YyAOMUaD/TyrJmYYAg1hZjeypR1ZWYDggyZ0jffHmO1JoZ3jboB IGDylRraacn59Glz2Ri0OYKWcQUVHUIwZP+xhOAMisThvuqDig== X-Google-Smtp-Source: AGHT+IGw/Iy/eaadIUi+2a+WycHO+GaHiGrtDGPPc2tTsFrWaYLQlkgnJOXVuKTDVxmslBj4y7WEnUavGY5fPGruzwo= X-Received: by 2002:ac2:5df4:0:b0:507:b074:ecd4 with SMTP id z20-20020ac25df4000000b00507b074ecd4mr6351835lfq.7.1700009601102; Tue, 14 Nov 2023 16:53:21 -0800 (PST) In-Reply-To: <871qcskzda.fsf@neko.mail-host-address-is-not-set> Received-SPF: pass client-ip=2a00:1450:4864:20::135; envelope-from=joaotavora@gmail.com; helo=mail-lf1-x135.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:312745 Archived-At: On Tue, Nov 14, 2023 at 5:40=E2=80=AFPM Tomas Hlavaty wrot= e: > > On Tue 14 Nov 2023 at 11:47, Jo=C3=A3o T=C3=A1vora = wrote: > > On Tue, Nov 14, 2023 at 10:55=E2=80=AFAM Po Lu wro= te: > > LOOP, pcase, etc, like any other macros, are mini-languages. Like > > any higher-level language, the more powerful they are, the more > > transformations they will do on your input. LOOP is pretty powerful, > > and may or may not be suitable for the task at hand, like any other > > language. > > The question is if those are "nice" mini-languages or expressing the > code in simple emacs-lisp is nicer. > > > At any rate Tomas' translation of the loop is just plain > > wrong. Where is 'type-spec' being bound? It needs to be > > destructured: > > Thanks, you found a bug in the sketch. It should have been: > > (puthash (pop f) (comp-type-spec-to-cstr (pop f)) h) > > or maybe > > (puthash (car f) (comp-type-spec-to-cstr (cadr f)) h) Yeah, this one's better. The pop is just confusing. As is the setq in the while condition, which my common lisp priests would not approve. But the dolist+destructuring-bind is pretty nice and solves all that. > (dolist (x comp-known-type-specifiers) > (destructuring-bind (f type-spec) x ...)) > > if emacs-lisp had destructuring-bind. But it does! in cl-lib.el no less :-) > (let ((h (make-hash-table :test #'eq))) > (dolist (x comp-known-type-specifiers h) > (apply (lambda (f type-spec) > (puthash f (comp-type-spec-to-cstr type-spec) h)) > x))) > This one is kinda hard to read for me, at least I couldn't tell if it was correct right way, putting a lambda in there confuses things (also if I not mistaken 'apply' instead of directly accessing the elements is slower). Anyway, I think (cl-loop with h =3D (make-hash-table :test #'eq) for (f type-spec) in comp-known-type-specifiers do (puthash f (puthash f (comp-type-spec-to-cstr type-spec) h) finally return h) is the comparable loop and I don't think it's so bad. It's one line less and less complex sexp tree. But all your solutions are nice too, so I guess I'm pretty tolerant. I don't know if I would write this loop myself because while the destructuring is nice, the return h spoils it, and the dolist gives you for free (if you know the mini-language ;-) ) Loop is really good (IMHO!) for complex iteration with repeat, counts, maximizations, early returns. I like loop's self-documenting properties. Complex iteration happens in programs, in all languages! Some things are hard regardless of the idiom, unless you learn the problem domain and the code is documented. Jo=C3=A3o