[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Macros in Dylan

Neel Krishnaswami <neelk@alum.mit.edu> writes:

> Peter J. Wasilko, Esq. writes:
> > 
> > Apple's Dylan language incorporated a Macro system that
> > distinguished between Definition Macros, Statment Macros, and
> > Function Macros (which seemed to have distinct hooks in the Dylan
> > grammar itself) along with a few other interesting features like a
> > provision for intentionally violating hygiene.
> > 
> > Has anyone on the list made use of those facilities, and if so,
> > could they comment on any lessons we might draw from the Dylan
> > experience?
> As a lower bound, Scott McKay, Eric Kidd, and Johnathon(sic)
> Bachrach all probably have more experience with Dylan's macros than
> I do, but here's my two cents:
> Dylan's macros are very similar to Scheme's syntax-rules macro system.
> That is, you write macros by defining a set of patterns the lexical
> syntax is matched against, and then the patterns are rewritten
> according to the matching templates. Unsurprisingly, the strengths and
> the weaknesses of Dylan's macros are very similar to Scheme's macro
> system. 
> Its great strength is that simple macros are easy to write, and its
> great weakness is that complex macros are an exercise in pain, since
> it's all but impossible to properly structure a macro. in fact, I
> think that this is one of the great weaknesses of most current macro
> languages: there's no good way to decompose a macro definition in the
> way that regular programs can be.

while this is true, keith playford and i have proposed extensions to
the original Dylan macro system (found in an appendix of
www.jbot.org/Projects/dexprs.htm) that make defining them much less
painful and structuring them much easier.  one improvement is to allow
direct macro calls.  also, in that paper we proposed an even more
general and easy to use procedural macro system for Dylan (which was
the precursor to the Java Syntactic Extender (JSE) www.jbot.org/jse/).