

Intuitive hygienic macros (2009) - luu
http://www.rntz.net/post/intuitive-hygienic-macros.html

======
jonathanyc
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-
macro...](http://wiki.call-cc.org/man/4/Macros#implicit-renaming-macros) [2]:
[http://wiki.call-cc.org/explicit-renaming-macros#implicit-
re...](http://wiki.call-cc.org/explicit-renaming-macros#implicit-renaming-
macros) [3]:
[https://www.gnu.org/software/guile/manual/html_node/Syntax-R...](https://www.gnu.org/software/guile/manual/html_node/Syntax-
Rules.html)

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
Are 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
That looks pretty neat! Thanks, I'm reading up on it now.

------
tempodox
I still prefer the down-and-dirty Lisp macros with explicit gensym. The
problems that hygienic macros are supposed to solve don't even exist in Lisp
(separate namespaces for functions & values, gensym _when_ you need it).

Sadly, the article doesn't even display a publishing date. A failure that
afflicts surprisingly many tech blog articles. Makes it harder to gauge its
merit.

~~~
rntz
I published it on 2009-03-03. Dates are listed at
[http://www.rntz.net/index.html](http://www.rntz.net/index.html) but not in
the articles themselves; I guess maybe I should fix that (not sure where a
good place to put the date would be).

I don't feel that separate function/value namespaces really solves the problem
of hygiene. It just makes it less likely to come up in practice. It's an 80%
solution: pragmatic but unsatisfying.

~~~
tempodox
You're right, separate namespaces don't actually “solve” the hygiene problem,
but rather place responsibility squarely in your lap. It's the usual trade of
more power for the price of more responsibility. What you call “unsatisfying”,
I call “open for more interesting constructs, if you're up to it”. I wonder
how many attempts might have been made to create a macro system that combines
wanted capture with hygiene...

As for article dates, I would expect a mature blogging platform to offer that
choice without forcing you to insert the date manually, but then I'm not a
blogger.

~~~
rntz
The article is about a macro system that gives you hygiene by default but
allows you to capture when you want it.

I'm not using a mature blogging platform.

