LISP and Symbolic Computation, 1(1)53-75
Expansion-Passing Style: A General Macro Mechanism
R. Kent Dybvig, Computer Science Department, Indiana University, Bloomington, IN 47405
Daniel P. Friedman, Computer Science Department, Indiana University, Bloomington, IN 47405
Christopher T. Haynes, Computer Science Department, Indiana University, Bloomington, IN 47405
|
Abstract: The traditional Lisp macro expansion facility
inhibits several important forms of expansion control. These include
selective expansion of subexpressions, expansion of subexpressions
using modified expansion functions, and expansion of application and
variable expressions. Furthermore, the expansion algorithm must treat
every special form as a separate case. The result is limited
expressive power and poor modularity. We propose an alternative
facility that avoids these problems, using a technique called
expansion-passing style (EPS). The critical difference between the
facility proposed here and the traditional macro mechanism is that
expansion functions are passed not only an expression to be expanded
but also another expansion function. This function may or may not be
used to perform further expansion. The power of this technique is
illustrated with several examples. Most Lisp systems may be adapted to
employ this technique.
|
[local copy]
|
|