Abstract
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.
Similar content being viewed by others
References
Steele Jr., Guy L.Common Lisp, the Language. Digital Press, second edition (1990).
Barendregt, H. P.The Lambda Calculus: Its Syntax and Semantics. Elsevier Science Publishers, revised edition (1984).
Bawden, Alan and Rees, Jonathan. Syntactic closures. InProceedings of the 1988 ACM Conference on Lisp and Functional Programming (July 1988) 86–95.
Clinger, William. Hygienic macros through explicit renaming.LISP Pointers, 4, 4 (1991).
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.
Clinger, William, Rees, Jonathan,et al. The revised4 report on the algorithmic language Scheme.LISP Pointers, 4, 3 (1991).
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.
Dybvig, R. Kent.The Scheme Programming Language. Prentice-Hall (1987).
Dybvig, R. Kent.Writing Hygienic Macros in Scheme with Syntax-Case. Technical Report 356, Indiana Computer Science Department (June 1992).
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.
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.
Griffin, Timothy G.Definition and Top-Down Refinement for Interactive Proof Development Systems. PhD thesis, Cornell University (August 1988).
Hanson, Chris. A syntactic closures macro facility.LISP Pointers, 4, 4 (1991).
Hennessy, J. Symbolic debugging of optimized code.ACM Transactions on Programming Languages and Systems, 4, 3 (July 1982) 323–344.
Kohlbecker, Eugene.Syntactic Extensions in the Programming Language Lisp. PhD thesis, Indiana University, Bloomington (August 1986).
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.
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.
Stoy, Joseph E.Denotational Semantics: The Scott-Strachey Approach to Programming Language Theory. MIT Press (1977).
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.
Author information
Authors and Affiliations
Additional information
This material is based on work supported by the National Science Foundation under grant number CCR-8803432.
Robert Hieb died in an automobile accident in April 1992.
Rights and permissions
About this article
Cite this article
Dybvig, R.K., Hieb, R. & Bruggeman, C. Syntactic abstraction in scheme. Lisp and Symbolic Computation 5, 295–326 (1993). https://doi.org/10.1007/BF01806308
Issue Date:
DOI: https://doi.org/10.1007/BF01806308