On 11 Sep 2009, at 4:34 pm, David Van Horn wrote: > Alaric Snell-Pym wrote: >> That's fine with me. I was leaning for "low-level hygienic macros in >> Thing One, as Thing Two can define syntax-rules and syntax-case in >> terms of them" > > What does "low-level hygienic macros" mean?
Ok, Scheme macro systems can be classified on two axes: * Low-level vs. High-level * A low-level macro is defined as some Scheme code that's handed the macro call expression, as an actual s-expression (perhaps with some magic around the symbols to deal with hygiene issues). It literally is a function from Scheme source code for a macro reference to Scheme source code of what the macro should be expanded to. It's low-level because you have to grovel around the input s-expr with car and cdr and so on, then cons up the expansion (quasiquotes help a lot here). A high-level macro, OTOH, has some specialist mini-language that does pattern-matching for you. Like syntax-rules, you specify input patterns (with variables in) and for each one, an output pattern or (as a more intermediate level) Scheme source code to assemble the expansion. * Hygienic vs. Filthy * Hygienic macros make it possible to control what scope (the scope of the macro definition, or of the macro invocation) each identifier in the expansion of the macro should be looked up in. So if your macro uses a helper function, it can refer to that helper function in its own scope and not worry about any other definition of that name interfering with it; if it uses things from other modules, it can likewise use its own scope (where the module defining the macro has imported said modules), so needn't worry about whether the using module/program has those modules loaded, what prefixes their identifiers have, and any clashes; and when it expands into a construct that binds some names (be they supplied by the caller of the macro as in some kind of let, or hardcoded into the macro), it can use the required names without them clashing with any names used internally in the macro. Hygienic macro systems may allow the author of the macro to explicitly break hygiene when they want to, by letting the choice of scope be in the hands of the macro author; or just hardcode it so that any identifiers that are free in the macro come from the macro's definition scope and that's that. Filthy dirty unhygienic macros, on the other hand, force all identifiers in the macro expansion to be considered in the scope of macro use, which makes it hard for the macro author to reliably access things from within the macro, and opens the door for names used internally in the macro to mess with the macro user's definitions. This has been explained much better (but more wordily) at http://lists.gnu.org/archive/html/chicken-users/2008-04/msg00013.html > > David > ABS -- Alaric Snell-Pym Work: http://www.snell-systems.co.uk/ Play: http://www.snell-pym.org.uk/alaric/ Blog: http://www.snell-pym.org.uk/archives/author/alaric/ _______________________________________________ r6rs-discuss mailing list [email protected] http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss
