Expansion-passing style: A general macro mechanism

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.

This is a preview of subscription content, log in to check access.

References

  1. 1.

    Charniak, E., Riesbeck, C.K., and McDermott, D.V., Meehan, J.R.,Artificial Intelligence Programming. Lawrence Erlbaum Associates, 1987.

  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.

  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.

  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.

  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.

  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.

  11. 11.

    Steele, G.L.Common LISP: The Language. Digital Press, 1984.

  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 

Download references

Author information

Affiliations

Authors

Additional information

A preliminary version of this paper was presented at the 1986 ACM Symposium on Lisp and Functional Programming. This material is based on work supported by the National Science Foundation under Grants MCS 83-04567, MCS 83-03325, and DCR 85-01277.

Rights and permissions

Reprints and Permissions

About this article

Cite this article

Dybvig, R.K., Friedman, D.P. & Haynes, C.T. Expansion-passing style: A general macro mechanism. Lisp and Symbolic Computation 1, 53–75 (1988). https://doi.org/10.1007/BF01806176

Download citation

Keywords

  • Artificial Intelligence
  • Special Form
  • Variable Expression
  • Critical Difference
  • Expressive Power