Sun Jul 20 03:28:30 CEST 2008
Looks like variable capture in macros is quite a bit more complicated
than I thought. Reading the MacroML paper:
Basicly, introducting binding forms during a source code
transformation requires the assurance that no free variables are
captured (= hygiene). A sure way of doing this is to use generated
names that come from a namespace exclusively allocated to that
particular source code transformation.
The other way around (referential transparency) the names introduced
should be related to those visible at syntax transformer definition
time, not those visible in the lexical expansion context.
As far as I understand, in MetaML and MacroML renaming is used also.
Q: what are freshness conditions?
No idea. Maybe this has to do with generated names?
The paper contains an interesting section about recursive macros and
'early' parameters: those necessarily evaluated to make sure expansion
Hmm.. So MetaML is really about evaluation order: making sure some
evaluations happen before other ones, independent of the language's
default normal/applicative order.
However, the point about substitution at the end of section 3 I don't
really understand. Why is there never any variable capture?