emacs-devel
[Top][All Lists]
Advanced

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

RE: [External] : Re: What's missing in ELisp that makes people want to u


From: Drew Adams
Subject: RE: [External] : Re: What's missing in ELisp that makes people want to use cl-lib?
Date: Sun, 12 Nov 2023 19:45:13 +0000

> 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.

FWIW:

"Don't Loop, Iterate":
https://iterate.common-lisp.dev/doc/Don_0027t-Loop-Iterate.html

"The Iterate Manual":
https://iterate.common-lisp.dev/iterate-manual.pdf





reply via email to

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