Bravo, awkravchuk/Andrew :^)
(Crossposted from https://mxjn.me/2024/10/17/1)
Read the first part when it came back, really excited to read this one. Kudos to the author!
I usually build command line Common Lisp apps in SBCL or LispWorks, but I might do the next one in ECL because having builds for both macOS and Linux would be cool, and it would be fun to try something new.
Love it!
As mentioned at the end of the article, the next Lisp Game Jam starts next week on the 25th. Join in here: https://itch.io/jam/autumn-lisp-game-jam-2024
For an even sillier mind bend, I'm using tagbody to be able to directly transcribe some of Knuth's algorithms as I am learning them.
If mindbending isn't relating to its usage, but to its implementation, then I could see, how it could still be a good thing.
Common Lisp happens to be on the upper end of what loop allows – you can use it as a standard for loop pretty easily, but the interface gives you many other options.
If you really wanna get freaky try 'do. It is the heroin addicted cousin of 'loop
https://www.lispworks.com/documentation/HyperSpec/Body/m_do_...
'do is much more general and way more powerful. in some sense 'loop is the taming of 'do. see for example
https://www.lispworks.com/documentation/lcl50/loop/loop-7.ht...
But in the meantime since discovering iterate I've barely used `loop`. It just feels so much more lispy and I find myself running to the documentation less often.
And it seems to lack all the iterations drivers (incl. builtin destructuring) that make half of loop/iterate's usefulness and "reads like English" comfy factor; especially liking
(for (i j) on list [by #'cddr])
(for i initially init-expr then then-expr)
(for prev previous i [initially init-expr])
(for i in-{file,stream} [using #'reader])
The two lasts are iterate goodies and I often use the last with these custom readers: https://git.sr.ht/~q3cpma/cl-utils/tree/master/item/src/read...It has limited destructuring - sequences can return multiple values, all of which can be bound. There's an adapter to convert one that does that into returning a single list, but not the other way around. If there was it could be used with `in-slice` to be equivalent to your first example.
I could probably write a new sequence to get the `previous` behavior; don't think `initially ... then` is possible.
Lots of sequences for reading from open ports (the Racket/Scheme name for CL streams)... `(for ([i (in-port)]) ...)` for example (with an optional reader argument defaulting to `read`).