skip to main content
10.5555/1792878.1792884guideproceedingsArticle/Chapter ViewAbstractPublication PagesConference Proceedingsacm-pubtype
Article

A theory of hygienic macros

Published: 29 March 2008 Publication History

Abstract

Hygienic macro systems, such as Scheme's, automatically rename variables to prevent unintentional variable capture--in short, they "just work." Yet hygiene has never been formally presented as a specification rather than an algorithm. According to folklore, the definition of hygienicmacro expansion hinges on the preservation of alpha-equivalence. But the only known notion of alpha-equivalence for programs with macros depends on the results of macro expansion! We break this circularity by introducing explicit binding specifications into the syntax of macro definitions, permitting a definition of alpha-equivalence independent of expansion. We define a semantics for a first-order subset of Scheme-like macros and prove hygiene as a consequence of confluence.

References

[1]
Kiselyov, O.: How to write seemingly unhygienic and referentially opaque macros with syntax-rules. In: Scheme Workshop (2002).
[2]
Kohlbecker, E., Friedman, D.P., Felleisen, M., Duba, B.: Hygienic macro expansion. In: LISP and Functional Programming (1986).
[3]
Clinger, W., Rees, J.: Macros that work. In: POPL (1991).
[4]
Bawden, A., Rees, J.: Syntactic closures. In: LISP and Functional Programming, pp. 86-95 (1988).
[5]
Kent Dybvig, R., Bruggeman, R.H., C.: Syntactic abstraction in Scheme. Lisp and Symbolic Computation 5(4), 295-326 (1993).
[6]
van Tonder, A.: SRFI 72: Hygienic macros. Online (September 2005).
[7]
Clinger, W., Rees, J.: Revised4 report on the algorithmic language Scheme. Technical report (1991).
[8]
Culpepper, R., Felleisen, M.: Taming macros. In: Karsai, G., Visser, E. (eds.) GPCE 2004. LNCS, vol. 3286, Springer, Heidelberg (2004).
[9]
Gabbay, M.J., Pitts, A.M.: A new approach to abstract syntax with variable binding. Formal Aspects of Computing 13(3-5), 341-363 (2001).
[10]
Gorn, S.: Explicit definitions and linguistic dominoes. In: Systems and Computer Science, Proceedings of the Conference held at Univ. of Western Ontario (1967).
[11]
Barendregt, H.P.: The Lambda Calculus: Its Syntax and Semantics. revised edn. North-Holland, Amsterdam (1984).
[12]
Wright, A.K., Felleisen, M.: A syntactic approach to type soundness. Information and Computation 115(1), 38-94 (1994).
[13]
Flatt, M.: PLT MzScheme: Language manual. Technical Report PLT-TR2007-1- v371, PLT Scheme Inc. (2007), http://www.plt-scheme.org/techreports/
[14]
Krishnamurthi, S.: Linguistic Reuse. PhD thesis, Rice University (May 2001).
[15]
de Rauglaudre, D.: Camlp4 reference manual. Online (September 2003).
[16]
Sheard, T., Peyton Jones, S.: Template metaprogramming for Haskell. In: Chakravarty, M.M.T. (ed.) Haskell Workshop, pp. 1-16 (2002).
[17]
Ganz, S.E., Sabry, A., Taha, W.: Macros as multi-stage computations: Type-safe, generative, binding macros in MacroML. In: ICFP 2001, pp. 74-85 (2001).
[18]
Taha, W., Johann, P.: Staged notational definitions. In: Pfenning, F., Smaragdakis, Y. (eds.) GPCE 2003. LNCS, vol. 2830, pp. 97-116. Springer, Heidelberg (2003).
[19]
Gasbichler, M.: Fully-parameterized, first-class modules with hygienic macros. PhD thesis, University of Tübingen (August 2006).
[20]
Griffin, T.: Notational definition--a formal account. In: LICS 1988, pp. 372-383 (1988).
[21]
Bove, A., Arbilla, L.: A confluent calculus of macro expansion and evaluation. In: LISP and Functional Programming, pp. 278-287. ACM Press, New York (1992).
[22]
McKinna, J., Pollack, R.: Some lambda calculus and type theory formalized. Journal of Automated Reasoning 23, 373-409 (1999).
[23]
Gordon, A.D.: A mechanisation of name-carrying syntax up to alpha-conversion. In: Workshop on HOL Theorem Proving and its Applications, pp. 413-425 (1994).
[24]
McBride, C., McKinna, J.: Functional pearl: I am not a number--I am a free variable. In: Haskell Workshop, pp. 1-9 (2004).
[25]
Kohlbecker, E.E., Wand, M.: Macro-by-example: Deriving syntactic transformations from their specifications. In: Principles of Programming Languages (1987).

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Guide Proceedings
ESOP'08/ETAPS'08: Proceedings of the Theory and practice of software, 17th European conference on Programming languages and systems
March 2008
398 pages
ISBN:3540787380

In-Cooperation

  • EAPLS: European Association for Programming Languages and Systems
  • EATCS: European Association for Theoretical Computer Science
  • European Association of Software Science and Technology

Publisher

Springer-Verlag

Berlin, Heidelberg

Publication History

Published: 29 March 2008

Qualifiers

  • Article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)0
  • Downloads (Last 6 weeks)0
Reflects downloads up to 14 Sep 2024

Other Metrics

Citations

Cited By

View all

View Options

View options

Get Access

Login options

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media