Earlier quoted context omitted.
How does that relate to a simple loop construct though? Why would you want that to be mind bending in interface or implementation? Every other language makes it as simple as possible.
This isn't really true – you have languages like Odin that only have a for loop, no while loop, that only supports index-based iteration. Then you have languages like Python that let you loop over an arbitrary iterable, and define your own iterables. Some languages allow conditionals in loops, some don't. Some let you loop over multiple iterables, while some only take one at a time. Common Lisp happens to be on the u…
Gamedev in Lisp. Part 2: Dungeons and Interfaces
41–50 of 68 posts
Re: Gamedev in Lisp. Part 2: Dungeons and Interfaces
#42Earlier quoted context omitted.
This isn't really true – you have languages like Odin that only have a for loop, no while loop, that only supports index-based iteration. Then you have languages like Python that let you loop over an arbitrary iterable, and define your own iterables. Some languages allow conditionals in loops, some don't. Some let you loop over multiple iterables, while some only take one at a time. Common Lisp happens to be on the u…
> 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_...
Re: Gamedev in Lisp. Part 2: Dungeons and Interfaces
#43The event loop is brilliant example for how much `loop` is a full blown iteration DSL... love it or hate it ;)
Why loop when you can https://iterate.common-lisp.dev/ instead? No s-expr-less alien syntax, no need for `do` to switch to back to Lisp syntax, normal `if`/`when` without the ugly `else`/`end` and generally useful features added.
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.
Re: Gamedev in Lisp. Part 2: Dungeons and Interfaces
#44Earlier quoted context omitted.
Why loop when you can https://iterate.common-lisp.dev/ instead? No s-expr-less alien syntax, no need for `do` to switch to back to Lisp syntax, normal `if`/`when` without the ugly `else`/`end` and generally useful features added.
If I used Common Lisp more I'd probably have a go at copying Racket's `for` forms[1]; they're really nice because you can usally tell at a glance what they're going to return - `for/list` returns a list for example. No having to scan the body for a `collect`. 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 ofte…
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...Re: Gamedev in Lisp. Part 2: Dungeons and Interfaces
#45This is super solid, but the setup in Part 1 (CL itself, Python, C, lots of steps) I think is indicative of why CL is not super popular, especially with young programmers. Which is a shame. Would be awesome if someone felt like putting in the work to make the language more approachable (installation wise).
Re: Gamedev in Lisp. Part 2: Dungeons and Interfaces
#46Earlier quoted context omitted.
If I used Common Lisp more I'd probably have a go at copying Racket's `for` forms[1]; they're really nice because you can usally tell at a glance what they're going to return - `for/list` returns a list for example. No having to scan the body for a `collect`. 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 ofte…
Interesting concept, but it visually has the same problem as loop IMO, using keywords to implement a new syntax instead of seamlessly blending with Lisp (at the cost of needing code walking, though). 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 in…
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`).
Re: Gamedev in Lisp. Part 2: Dungeons and Interfaces
#47Earlier quoted context omitted.
> 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 very straightforward and basic compared to the things that `loop` allows.
'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...
Re: Gamedev in Lisp. Part 2: Dungeons and Interfaces
#48Earlier quoted context omitted.
`do` is very straightforward and basic compared to the things that `loop` allows.
oh no. maybe you have in mind 'dolist or 'dotimes '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...
Re: Gamedev in Lisp. Part 2: Dungeons and Interfaces
#49Earlier quoted context omitted.
oh no. maybe you have in mind 'dolist or 'dotimes '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...
No, I mean do. It's basically just a C style for loop except with a return value. Nothing special.