Advertisement

LISP and Symbolic Computation

, Volume 1, Issue 1, pp 53–75 | Cite as

Expansion-passing style: A general macro mechanism

  • R. Kent Dybvig
  • Daniel P. Friedman
  • Christopher T. Haynes
Article

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 calledexpansion-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.

Keywords

Artificial Intelligence Special Form Variable Expression Critical Difference Expressive Power 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Charniak, E., Riesbeck, C.K., and McDermott, D.V., Meehan, J.R.,Artificial Intelligence Programming. Lawrence Erlbaum Associates, 1987.Google Scholar
  2. 2.
    Dybvig, R.K.The Scheme Programming Language. Prentice-Hall, Englewood Cliffs, NJ, 1987.Google Scholar
  3. 3.
    Liongosari, E.S.Scheme Debugger User's Manual. Undergraduate Honors Thesis, Indiana University, Bloomington, July 1987.Google Scholar
  4. 4.
    Dybvig, R.K., Friedman, D.P., and Haynes, C.T. Expansion-passing style: Beyond conventional macros. Proceedings of the 1986 ACM Conference on Lisp and Functional Programming. Cambridge, MA, 1986, pp. 143–150.Google Scholar
  5. 5.
    Fischer, M.J. Lambda calculus schemata. Proceedings of the ACM Conference on Proving Assertions about Programs, Las Cruces, New Mexico, 1972, pp. 104–109.Google Scholar
  6. 6.
    Kohlbecker, E.Syntactic Extensions in the Programming Language Lisp. Ph.D. dissertation, Indiana University, Bloomington, August 1986.Google Scholar
  7. 7.
    Kohlbecker, E., Friedman, D., Felleisen, M., and Duba, B. Hygienic macro expansion. Proceedings of the 1986 ACM Conference on Lisp and Functional Programming, Cambridge, MA, 1986, pp. 151–161.Google Scholar
  8. 8.
    Kohlbecker, E., and Wand, M. Macro-by-example: Deriving syntactic transformations from their specifications. Conference Record of the Fourteenth Annual ACM Symposium on Principles of Programming Languages, Munich, Germany, 1987, pp. 77–84.Google Scholar
  9. 9.
    Plotkin, G. Call-by-name, call-by-value, and the λ-calculus.Theoretical Computer Science 1 (1975) 125–159.Google Scholar
  10. 10.
    Rees J., and Clinger, W. (Eds.). Revised3 report on the algorithmic language Scheme. SIGPLANNotices 21, 12 (1986) 37–79.Google Scholar
  11. 11.
    Steele, G.L.Common LISP: The Language. Digital Press, 1984.Google Scholar
  12. 12.
    Steele, G.L. LAMBDA: The ultimate declarative. Artificial Intelligence Memo No. 379, MIT, Cambridge, MA, 1976.Google Scholar
  13. 13.
    Stoy, J.Denotational Semantics: The Scott-Strachey Approach to Programming Language Theory. MIT Press, Cambridge, MA, 1977.Google Scholar

Copyright information

© Kluwer Academic Publishers 1988

Authors and Affiliations

  • R. Kent Dybvig
    • 1
  • Daniel P. Friedman
    • 1
  • Christopher T. Haynes
    • 1
  1. 1.Computer Science DepartmentIndiana UniversityBloomington

Personalised recommendations