LISP and Symbolic Computation

, Volume 5, Issue 4, pp 295–326 | Cite as

Syntactic abstraction in scheme

  • R. Kent Dybvig
  • Robert Hieb
  • Carl Bruggeman


Naive program transformations can have surprising effects due to the interaction between introduced identifier references and previously existing identifier bindings, or between introduced bindings and previously existing references. These interactions can result in inadvertent binding, or capturing, of identifiers. A further complication is that transformed programs may have little resemblance to original programs, making correlation of source and object code difficult. This article describes an efficient macro system that prevents inadvertent capturing while maintaining the correlation between source and object code. The macro system allows the programmer to define program transformations using an unrestricted, general-purpose language. Previous approaches to the capturing problem have been inadequate, overly restrictive, or inefficient, and the problem of source-object correlation has been largely unaddressed. The macro system is based on a new algorithm for implementing syntactic transformations and a new representation for syntactic expressions.


Syntactic Abstraction Macros Program Transformation Hygienic Macros 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Steele Jr., Guy L.Common Lisp, the Language. Digital Press, second edition (1990).Google Scholar
  2. 2.
    Barendregt, H. P.The Lambda Calculus: Its Syntax and Semantics. Elsevier Science Publishers, revised edition (1984).Google Scholar
  3. 3.
    Bawden, Alan and Rees, Jonathan. Syntactic closures. InProceedings of the 1988 ACM Conference on Lisp and Functional Programming (July 1988) 86–95.Google Scholar
  4. 4.
    Clinger, William. Hygienic macros through explicit renaming.LISP Pointers, 4, 4 (1991).Google Scholar
  5. 5.
    Clinger, William and Rees, Jonathan. Macros that work. InConference Record of the Eighteenth Annual ACM Symposium on Principles of Programming Languages (January 1991) 155–162.Google Scholar
  6. 6.
    Clinger, William, Rees, Jonathan,et al. The revised4 report on the algorithmic language Scheme.LISP Pointers, 4, 3 (1991).Google Scholar
  7. 7.
    Coutant, D., Meloy, S., and Ruscetta, M. DOC: A practical approach to source-level debugging of globally optimized code. InProceedings of the SIGPLAN '88 Conference on Programming Language Design and Implementation (July 1988) 125–134.Google Scholar
  8. 8.
    Dybvig, R. Kent.The Scheme Programming Language. Prentice-Hall (1987).Google Scholar
  9. 9.
    Dybvig, R. Kent.Writing Hygienic Macros in Scheme with Syntax-Case. Technical Report 356, Indiana Computer Science Department (June 1992).Google Scholar
  10. 10.
    Dybvig, R. Kent, Friedman, Daniel P., and Haynes, Christopher T. Expansion-passing style: Beyond conventional macros. InProceedings of the 1986 ACM Conference on Lisp and Functional Programming (1986) 143–150.Google Scholar
  11. 11.
    Dybvig, R. Kent, Friedman, Daniel P., and Haynes, Christopher T. Expansion-passing style: A general macro mechanism.Lisp and Symbolic Computation, 1, 1 (1988) 53–75.Google Scholar
  12. 12.
    Griffin, Timothy G.Definition and Top-Down Refinement for Interactive Proof Development Systems. PhD thesis, Cornell University (August 1988).Google Scholar
  13. 13.
    Hanson, Chris. A syntactic closures macro facility.LISP Pointers, 4, 4 (1991).Google Scholar
  14. 14.
    Hennessy, J. Symbolic debugging of optimized code.ACM Transactions on Programming Languages and Systems, 4, 3 (July 1982) 323–344.Google Scholar
  15. 15.
    Kohlbecker, Eugene.Syntactic Extensions in the Programming Language Lisp. PhD thesis, Indiana University, Bloomington (August 1986).Google Scholar
  16. 16.
    Kohlbecker, Eugene and Wand, Mitchell. Macro-by-example: Deriving syntactic transformations from their specifications. InConference Record of the Fourteenth Annual ACM Symposium on Principles of Programming Languages (1987) 77–84.Google Scholar
  17. 17.
    Kohlbecker, Eugene, Friedman, Daniel P., Felleisen, Matthias, and Duba, Bruce. Hygienic macro expansion. InProceedings of the 1986 ACM Conference on Lisp and Functional Programming (1986) 151–161.Google Scholar
  18. 18.
    Stoy, Joseph E.Denotational Semantics: The Scott-Strachey Approach to Programming Language Theory. MIT Press (1977).Google Scholar
  19. 19.
    Zellweger, P. An interactive high-level debugger for control-flow optimized programs. InProceedings of the ACM Software Engineering Symposium on High-Level Debugging (August 1983) 159–171.Google Scholar

Copyright information

© Kluwer Academic Publishers 1993

Authors and Affiliations

  • R. Kent Dybvig
    • 1
  • Robert Hieb
    • 1
  • Carl Bruggeman
    • 1
  1. 1.Indiana University Computer Science DepartmentBloomington

Personalised recommendations