Hi Marijin,
On Monday 26 March 2012 at 18:01, Marijn wrote:
According to that paper, symbol macros aka identifier macros are needed to make this work.
Yes, some form of symbol macros are required to make it work. Gambit's namespace mechanism is similar to symbol macros, and is actually sufficient.
In fact, in my experiments with this type of macro system, I have found that it is easier to reason about the hygienic properties of the system if you have a limited symbol macro system, one where symbols must expand to "qualified" symbols, and where only "non-qualified" symbols can be declared as symbol macros. Which is exactly how Gambit's namespace system works.
So Gambit's namespace system is in a sense even better than symbol macros for this particular purpose.
To work, the namespace mechanism has to run as part of (as opposed to before or after) the macro expander, that is, namespace "expansions" have to be able to happen in between macro invocations. I'm not sure if it works like that right now, but it should be possible to change it if it doesn't.
To make this possible, defining a name that is already defined must be disallowed. I would make it a compilation error.
Almost stopped reading after that last sentence there!
Oops. I should have been clearer.
I would love to hear what you think about this.
I would be interested in knowing how this proposal compares with implementing a low-level hygienic macro system such as syntactic closures or explicit renaming macros. Actually now that I said that this proposal sounds very much like a (partial?) implementation of explicit renaming macros on top of the defmacro system. Doesn't the paper you referenced mention something like that as well?
I am familiar with syntactic closures, since that's what Black Hole's macro system is based on. I am less familiar with explicit renaming, but I think the same applies to them:
Syntactic closures (the type of object returned by |make-syntactic-closure|) are a special form of identifier, one that is not a symbol; it's a symbol (or sexp) together with some opaque information about the hygienic environment. Syntactic closures can not be compared like symbols (because they aren't symbols), you have to use a special |identifier=?| function.
In a similar way, explicit renaming requires you to compare identifiers with a special comparison predicate.
So: Both explicit renaming and syntactic closures introduce some kind of new, opaque object type for identifiers; symbols are not enough.
The system in this proposal does not require a separate "identifier" type; plain symbols are enough. In my opinion this makes the system much easier to reason about, I find it quite difficult to understand the concept of passing around hygienic environments as first class values.
This was what I was talking about when I said this in the summary: "[The system] has semantics that is very easy to reason about and does not introduce any fundamentally new concepts [symbols are no longer the only type of identifier] to the language"
Regards,
Per