Unhygienic and referentially opaque macros with Scheme syntax-rules [pdf] (2013)
okmij.org
okmij.org
If you're reading this paper, but haven't used Scheme much yet, three things to be aware of:
1. `syntax-rules` is nice, but there's much more powerful and easier to use constructs now, like `syntax-case` and Racket's `syntax-parse`.
2. When you see Oleg doing something like breaking `syntax-rules`, I think it's usually not like a pitfall of C or C++ that anyone could make inadvertently, and more like you probably have to be as knowledgeable and clever as Oleg to break it this way. It's more something to come back to, after you've already learned to use these very nice and powerful tools, so you can appreciate it, and not just get confused or scared.
3. Some of Oleg's Scheme software has been repackaged to make it easier to use. For example: https://docs.racket-lang.org/sxml/ (Also, Oleg's SXML became a de facto standard for representing XML and HTML in Scheme, and some of us have tried to make other tools compatible: https://docs.racket-lang.org/sxml-intro/#%28part._.Tools%29 )
`syntax-parse` is the best! I wrote up some notes [1] while trying to figure out the differences between `syntax-case` and `syntax-parse` a year ago. Not the best notes, but there are some examples.
Racket solves the hygiene problem well with scope sets: each identifier gets tagged with the set of scopes it appears in. There's a blog post [2] by Matthew Flatt of Racket fame describing how Racket's scope system works. Thanks to scope sets, I'm not sure this inadvertent variable capture would be a problem.
[1]: https://lambdaland.org/posts/2023-05-19_racket_macros/ [2]: https://users.cs.utah.edu/plt/scope-sets/
For clarity, I would specify that Matthew is the lone conceiver and implementer of the original sets-of-scopes system, as evidenced by him being the only author on the corresponding paper "Binding as Sets of Scopes" (POPL '16, DOI: https://doi.org/10.1145/2914770.2837620). So the blog post isn't just "some well-known Racket guy explaining a Racket thing", but rather "the guy who invented the thing explaining the thing".
The paper has a corresponding talk as well: https://youtu.be/rs27lkgq3Og. (And, in fact, Matthew has given the talk on more than a few occasions at various venues, so there are other recordings available as well.)
I guess that is what you get from starting with (chibi loop) and bolting on a lot of extra features.
0: I ended up with things like this: https://git.sr.ht/~bjoli/goof-loop/tree/master/item/goof/goo...