4 ms·
> LOOP is not extensible The standardized LOOP is not extensible. Each LOOP implementation is extensible. A common extension is to provide new loop iteration p
by lispm 4y ago
> LOOP is not extensible
The standardized LOOP is not extensible. Each LOOP implementation is extensible. A common extension is to provide new loop iteration paths.
LispWorks:
CL-USER 7 > (lispworks:defloop (s-element s-elements) elt length sequence t)
(S-ELEMENT S-ELEMENTS)
Now we can iterate over sequences in a not performance optimized version:
CL-USER 8 > (loop for e being each s-element of "hello-world" count e)
11
CL-USER 9 > (loop for e being each s-element of '(hello world) count e)
2
There are portable extensible LOOP implementations. This is then just as non-standard as any self-defined iteration library.
https://research.gold.ac.uk/id/eprint/2344/1/sequences-20070301.pdf https://research.gold.ac.uk/id/eprint/2344/1/sequences-20070... gives an example to extend SBCL's LOOP (which is based on the MIT LOOP implementation).
There are lots of things in the Common Lisp standard, which are not extensible, but where implementations and libraries provide extensible versions. Example: the CLOS MOP, sequences, hash tables, ...
- lisper 4y ago> Each LOOP implementation is extensible. Allegro isn't. Neither is SBCL. Nor CCL. Nor CLisp. In fact, the only implementation that offers this feature AFAICT is Lispworks. > There are lots of things in the Common Lisp standard, which are not extensible Sure. So? Just because loop is not the only thing in CL that sucks does not make it suck any less.
- lispm 4y agoPretty much all of those are extensible, especially given that a) they are provided in source code and b) those LOOP macro implementations have internal extension features. The paper I've linked gives an example how to extend LOOP in SBCL for iteration over sequences.