[Top][All Lists]

[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: Jim Porter
Subject: Re: What's missing in ELisp that makes people want to use cl-lib?
Date: Sat, 28 Oct 2023 14:03:29 -0700

On 10/28/2023 12:14 PM, Eli Zaretskii wrote:
Date: Sat, 28 Oct 2023 12:10:23 -0700
Cc: emacs-devel@gnu.org
From: Jim Porter <jporterbugs@gmail.com>

I agree with this. I can speak about Eshell in particular, since it's
historically used a bit of cl-lib, and I've added more usage to it.

By far the number one cl-lib thing Eshell uses is 'cl-assert'.

cl-assert is a macro in cl-macs, so it isn't relevant to this

Thanks. I wasn't aware of this distinction. (I see that it was discussed elsewhere in the parent thread, but that thread is very big and I hadn't been following it closely.)

Is there any benefit in aliasing macros like this to non 'cl-FOO' names anyway? As a mere consumer of the various Common Lisp code in Emacs, it's not always clear to me what's ok to use versus what should ideally be avoided.

Finally, Eshell uses a few miscellaneous cl-lib functions, some of which
are probably necessary, and some of which are just conveniences. The
(probable) necessities are: cl-progv and cl-mapc. The conveniences are:
cl-loop, cl-flet, cl-list*, cl-remove-if, cl-incf, and cl-decf.

These are the only ones relevant to this discussion.

I see that 'cl-progv' is in cl-macs.el, so I guess that's not relevant. 'cl-mapc' is in cl-extra.el, which I suppose is relevant here? I find it very helpful, but I'd be happy with any function/macro that would make it easy to iterate over multiple sequences at once.

Of the conveniences, I think the ones I'd miss the most are 'cl-incf' and 'cl-decf', which I use in Eshell for recounting some handles. (I could possibly rewrite that code to let the garbage collector do all the work, but that code interacts with some of the trickier bits in Eshell, so maybe it's best not to change it too much.)

'cl-remove-if' should be easy to replace with 'seq-filter' or somesuch. Likewise 'cl-list*' with 'nconc'. I know there's some controversy around 'cl-loop' (I'm not a big fan myself), and I've thought about adding some new hooks to Eshell that would probably obviate the need for 'cl-loop' (which is used in em-extpipe.el).

So in conclusion, I guess the relevant functions that I care about are 'cl-mapc', and to a lesser degree 'cl-incf'/'cl-decf'. Everything else could go away if we wanted to avoid them.

reply via email to

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