4 ms·
It is well worth a mention that srfi-42 inspired racket's loops. It is actually a pretty neat looping protocol, and I ended up looking at it quite a lot for ins
by bjoli 8y ago
It is well worth a mention that srfi-42 inspired racket's loops. It is actually a pretty neat looping protocol, and I ended up looking at it quite a lot for inspiration when implementing my own loop facilities.
The reference implementation is pretty cool since it is implemented only using syntax-rules (the standardised high level, strictly hygienic macro facility of scheme). That is a special level of masochism right there, but it is probably also why the reference implementation has to use set! instead of generating pure tail-recursive (and thus continuation safe) code.
I ended up implementing something not unlike racket's for guile scheme [0] using syntax-case. I find that syntax easier to work with and understand, and the code generated is better than srfi-42. In fact it is almost always zero overhead, just like racket's loops.
[0]:https://bitbucket.org/bjoli/guile-for-loops https://bitbucket.org/bjoli/guile-for-loops the readme is not really correct. I now support both pre-checks and lazy loops, but I am cleaning some things up for a first release. The docs are here: https://koketteriet.se/software/guile-for-loops/docs.html https://koketteriet.se/software/guile-for-loops/docs.html