Summary
Hygenic macros can not access the local scope where they are expanded, while unhygenic macros (as found in C) can. I want the best of both worlds!
Advertisement
Unhygenic macros can access the local scope where they are expanded. This is a dangerous and often unwelcome thing because it can lead to very subtle bugs and name clashes. However, it makes it very easy to write clever AOP style code, I can use it to implement Programming with Contracts, and tons of other nifty things.
A lot of people gave me a kick in the pants for not having hygenic macros ala Common Lisp. So I thought how about both? A regular old hackish macro is defined in Heron as follows:
The dollar signs convert meta-values to values accessible at run-time, and # expands code (and macros).
Now the question is how should I syntactically differentiate a hygenic macro? Perhaps:
Another option, which I kind of like, is a hybrid macro. This is a hygenic macro which has limited access to the local context (i.e. where it is expanded) through some kind of special context meta-variable (for instance _context). To illustrate what I mean, consider the pseudo-code: