[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: |
Eli Zaretskii |
Subject: |
Re: What's missing in ELisp that makes people want to use cl-lib? |
Date: |
Sun, 12 Nov 2023 08:45:06 +0200 |
> From: Richard Stallman <rms@gnu.org>
> Cc: emacs-devel@gnu.org
> Date: Sat, 11 Nov 2023 21:57:02 -0500
>
> > But when you need to process plists, for example, it becomes
> > very handy. This construct, which does require knowing a bit
> > of the mini-language that is cl-loop,
>
> > (cl-loop for (k v) on plist by #'cddr collect (cons k v))
>
> It is certainly concise. If I saw that code I would not understand it,
> but if you said what job it does I could see how it might do that.
>
> That's because cl-loop defines its own little language, which I don't know.
Btw, the above is a very simple use of cl-loop. We have quite a few
of much more complex ones. For example:
(cl-loop
with comp-ctxt = (make-comp-cstr-ctxt)
with h = (make-hash-table :test #'eq)
for (f type-spec) in comp-known-type-specifiers
for cstr = (comp-type-spec-to-cstr type-spec)
do (puthash f cstr h)
finally return h)
or this:
(cl-loop for i = 0 then (+ i (if (eq (nth i list) ?\\) 4 1))
for var = (nth i list)
while (< i size)
if (eq var ?\\)
collect (string-to-number
(concat (cl-subseq list (+ i 1) (+ i 4))) 8)
else
collect var))
or this:
(cl-loop
named loop
with above
for lane in (comp-cstr-ctxt-typeof-types comp-ctxt)
do (let ((x (memq type lane)))
(cond
((null x) nil)
((eq x lane) (cl-return-from loop x)) ;A base type: easy case.
(t (setq above
(if above (comp--intersection x above) x)))))
finally return above))
It isn't an accident that the reference documentation of cl-loop in
cl.info takes a whopping 700(!) lines.
- Re: What's missing in ELisp that makes people want to use cl-lib?, (continued)
- Re: What's missing in ELisp that makes people want to use cl-lib?, Richard Stallman, 2023/11/17
- Re: What's missing in ELisp that makes people want to use cl-lib?, Gerd Möllmann, 2023/11/14
- Re: What's missing in ELisp that makes people want to use cl-lib?, Michael Heerdegen, 2023/11/13
- Re: What's missing in ELisp that makes people want to use cl-lib?, João Távora, 2023/11/13
- Re: What's missing in ELisp that makes people want to use cl-lib?, Michael Heerdegen, 2023/11/14
- Re: What's missing in ELisp that makes people want to use cl-lib?, Gerd Möllmann, 2023/11/15
- Re: What's missing in ELisp that makes people want to use cl-lib?, João Távora, 2023/11/16
- Re: What's missing in ELisp that makes people want to use cl-lib?, Richard Stallman, 2023/11/11
- Re: What's missing in ELisp that makes people want to use cl-lib?,
Eli Zaretskii <=
- RE: [External] : Re: What's missing in ELisp that makes people want to use cl-lib?, Drew Adams, 2023/11/12
- Re: What's missing in ELisp that makes people want to use cl-lib?, Richard Stallman, 2023/11/13
- RE: [External] : Re: What's missing in ELisp that makes people want to use cl-lib?, Drew Adams, 2023/11/14
- Re: What's missing in ELisp that makes people want to use cl-lib?, Tomas Hlavaty, 2023/11/14
- Re: What's missing in ELisp that makes people want to use cl-lib?, João Távora, 2023/11/14
- Re: What's missing in ELisp that makes people want to use cl-lib?, Po Lu, 2023/11/14
- Re: What's missing in ELisp that makes people want to use cl-lib?, João Távora, 2023/11/14
- Re: What's missing in ELisp that makes people want to use cl-lib?, Po Lu, 2023/11/14
- Re: What's missing in ELisp that makes people want to use cl-lib?, João Távora, 2023/11/14
- Re: What's missing in ELisp that makes people want to use cl-lib?, Po Lu, 2023/11/14