[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 12:10:23 -0700

On 10/28/2023 8:39 AM, Stefan Kangas wrote:
Is it possible that certain abstractions or functions are filling a gap
in Emacs Lisp itself?  In the case of `cl-pushnew', I happen to think
that the answer is yes.

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'. This would be reasonably easy to do without cl-lib, but it's a pretty convenient syntax for, well... asserting some precondition for a function. That's been useful for helping to identify subtle bugs in Eshell's logic.

After that, the next most important cl-lib thing (in my opinion) is generic functions. I introduced this in Eshell to break apart some monolithic I/O code that had large 'cond' forms for each I/O target. Now, with generic functions, they're separate, and it's much easier for third parties to add new I/O target types. In the future, I'll likely use generic functions for a few more bits in Eshell.

Related to the above is 'cl-defstruct'. That's useful for working with generic functions, but I think there's also some benefit to using them instead of lists (or alists/plists) when you want something with a very-specific set of members (similar to a C struct or C++ class). However, I could do without CL-style structs for this case, excluding the generic function side.

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.

reply via email to

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