Hi Tom, On Sat 05 Sep 2009 23:15, Thomas Lord <[email protected]> writes:
> On Sat, 2009-09-05 at 15:41 -0400, John Cowan wrote: > >> What makes macro hygiene critical, I think, is that it can't be emulated >> without being able to do a global transformation of all code, not merely >> macro definitions and calls. > > That's not quite true. > > As I recall, the way we added hygienic macros to > Guile was... Interesting history. I must have missed this bit; since I've been using Guile, hygienic expansion has been provided by psyntax, without knowledge of first-class environments. There was a long time, since about 1997 or so, in which most code was *not* run through a hygienic expander in Guile -- until earlier this year, actually -- but that was an unsatisfying situation. > 1) Started with something a bit like classic old > defmacro, but that memoizes its results. That is, > upon first execution, unexpanded macro calls are > replaced with their expansion by doing local, not > global code rewriting. This bit was inherited from > SCM. > > 2) Adding first class environments and locatives. > An F.C.E. is a mapping from names to locatives. A > locative is the anonymous binding site of a variable. Up to here I am aware of this. This system has lovely advantages for an interpreter, but it's not amenable to compilation. > 3) Writing the hygienic system on top of that is > tedious - easy to make mistakes and took a few iterations > before it was more or less correct - but its conceptually > straightforward. Tedious indeed. I'd rather run all code through an expander before doing anything else with it, be it interpretation or compilation or whatever. > A module system can also be built similarly. This is one legacy of your Guile days that I really like -- first-class modules. Of course, they aren't predicated on runtime lexical environments to have them. > Would one approach be better than the other? > I would only say that first class environments are > a natural fit for most interpretation strategies, Agreed. > that they can be given a nice clean semantics, Uf. As long as you don't want to compile, because in that case you either give up good code, or implement a different semantics. > and that they are a more general purpose tool > than hygienic macros. Hard to say, my friend. I've grown to like psyntax's effects, if not its implementation. Cheers, A -- http://wingolog.org/ _______________________________________________ r6rs-discuss mailing list [email protected] http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss
