Skip to main content



Composable and Compilable Macros - You Want it When?

Matthew Flatt

Presented by Scott Messick on February 17, 2017

Many macro systems, especially for Lisp and Scheme, allow macro transformers to perform general computation. Moreover, the language for implementing compile-time macro transformers is usually the same as the language for implementing run-time functions. As a side effect of this sharing, implementations tend to allow the mingling of compile-time values and run-time values, as well as values from separate compilations. Such mingling breaks programming tools that must parse code without executing it. Macro implementors avoid harmful mingling by obeying certain macro-definition protocols and by inserting phase-distinguishing annotations into the code. However, the annotations are fragile, the protocols are not enforced, and programmers can only reason about the result in terms of the compiler’s implementation. MzScheme - the language of the PLT Scheme tool suite - addresses the problem through a macro system that separates compilation without sacrificing the expressiveness of macros.

PDF