
Eager Comprehensions (2003) - pmoriarty
https://srfi.schemers.org/srfi-42/srfi-42.html
======
bjoli
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)

~~~
soegaard
Note that it is possible to implement SRFI-42 using `syntax-rules` - the only
available macro system in R5RS.

~~~
bjoli
That's what I said :)

Come to think of it, a large subset of racket's for loops is possible to
implement using syntax rules, but I wouldn't recommend it.

