emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What's missing in ELisp that makes people want to use cl-lib?


From: João Távora
Subject: Re: What's missing in ELisp that makes people want to use cl-lib?
Date: Tue, 14 Nov 2023 11:47:51 +0000

On Tue, Nov 14, 2023 at 10:55 AM Po Lu <luangruo@yahoo.com> wrote:

> The transformations carried out by cl-loop are by a
> long shot more consequential to the structure of their input than those
> by most any other macro there is

That's true.

> , which is a demerit

That's not.

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.

At any rate Tomas' translation of the loop is just plain
wrong.  Where is 'type-spec' being bound?  It needs to be
destructured: LOOP is a language which is very good
at expressing this fact concisely in a self-documenting way:

  for (f type-spec) in comp-known-type-specifiers

Here from this one line, without ever having looked at Andrea's
code I learn that comp-known-type-specifiers is a list of
2-element lists, where each such tuple is at least made of
an 'f' and a 'type-spec'.

It would take longer (for me!) to learn this fact if
'car' and 'cadr' had been used in subsequent forms away from
detached from a hypothetical (pop comp-known-type-specifiers).

But again, that's just for me, and that's because I have learned
the LOOP language, because I thought it was worth learning
just for reading other people's code.  And it sure was.

But if you don't want to learn it, for whatever personal reason,
open up the macroexpansion, or step through the function with
edebug.  To each his own.

Anyway Tomas' example, if it were to be corrected, would become
"ugly" perhaps "uglier" (as if "ugly" were even an objective
thing)

Here, I think dolist + pcase-let/cl-destructuring-case/seq-let
would also be appropriate.  Though I'm sure someone out there
would find it insufferably ugly or anti-Elisp as well.

João



reply via email to

[Prev in Thread] Current Thread [Next in Thread]