5 ms·
This looks to me like essentially CHICKEN's implicit renaming macros[1][2]. It's interesting how good ideas evolve convergently. (For a bit of nitpicking, I'm
by jonathanyc 12y ago
This looks to me like essentially CHICKEN's implicit renaming macros[1][2]. It's interesting how good ideas evolve convergently.
(For a bit of nitpicking, I'm aware the author generalizes on purpose, but I'm surprised that Lispers would actually find syntax-rules confusing (though the part about inflexibility I understand (although even so, unhygienic macros have been in Scheme implementations for a long time)) syntax-rules[3] is the clearest way to define macros I've ever seen (like implicit renaming macros without an option to 'inject', hence ir-macro-transformer).)
[1]: http://wiki.call-cc.org/man/4/Macros#implicit-renaming-macros http://wiki.call-cc.org/man/4/Macros#implicit-renaming-macro...
[2]: http://wiki.call-cc.org/explicit-renaming-macros#implicit-renaming-macros http://wiki.call-cc.org/explicit-renaming-macros#implicit-re...
[3]: https://www.gnu.org/software/guile/manual/html_node/Syntax-Rules.html https://www.gnu.org/software/guile/manual/html_node/Syntax-R...
Edit: I did some more research and it seems this article predated CHICKEN 4.7.0, which introduced ir-macro-transformer, by two years. That's pretty cool - I wonder if the article inspired CHICKEN, or if it was, like I supposed earlier, convergent evolution.
- lomnakkus 12y agoAre you familiar with Racket's define-syntax/syntax-parse? It's another step up in terms of power and actually allows for decent error handling!
- jonathanyc 12y agoThat looks pretty neat! Thanks, I'm reading up on it now.
- rntz 12y agoArticle author here. I don't actually remember why I found syntax-rules confusing, although I can make a couple of guesses: 1. Doing simple things with syntax-rules is simple, and that's most of what you use syntax-rules for, but it is actually possible to do very powerful things with it (Oleg Kiselyov has done terrifying things with it, for example). However, doing this is rather involved and complex. 2. Perhaps I preferred the conceptual simplicity of the lisp model that "a macro is just a function that returns an s-expression". syntax-rules is "yet another language" to learn (albeit a very simple one), while macros just reuse the lisp functions you already know. I hadn't seen Chicken's "implicit-renaming macros" until now, so thanks for the link!