Sciweavers

Share
ICFP
2001
ACM

Macros as Multi-Stage Computations: Type-Safe, Generative, Binding Macros in MacroML

9 years 7 months ago
Macros as Multi-Stage Computations: Type-Safe, Generative, Binding Macros in MacroML
With few exceptions, macros have traditionally been viewed as operations on syntax trees or even on plain strings. This view makes macros seem ad hoc, and is at odds with two desirable features of contemporary typed functional languages: static typing and static scoping. At a deeper level, there is a need for a simple, usable semantics for macros. This paper argues that these problems can be addressed by formally viewing macros as multi-stage computations. This view eliminates the need for freshness conditions and tests on variable names, and provides a compositional interpretation that can serve as a basis for designing a sound type system for languages supporting macros, or even for compilation. To illustrate our approach, we develop and present MacroML, an extension of ML that supports inlining, recursive macros, and the definition of new binding constructs. The latter is subtle, and is the most novel addition in a statically typed setting. The semantics of a core subset of MacroML...
Steven E. Ganz, Amr Sabry, Walid Taha
Added 13 Dec 2009
Updated 13 Dec 2009
Type Conference
Year 2001
Where ICFP
Authors Steven E. Ganz, Amr Sabry, Walid Taha
Comments (0)
books