Macro
The term for a way to extend the syntax and semantics of a programming language; they are a special case of compile-time rewrite.Macros operate at the level of a structure in which the language is modeled, which can be at various levels: theoretical monads, abstract syntax trees, lexer tokens, or character strings. The higher-level methods of doing this generally offer cleaner methods of expressing these transformations, and are preferred when accessible.
They are a particular case of metaprogramming, done within a language itself, as a restricted form of compile-time reflection?. The integration of macros with general compile-time reflection requires the availability of suitable ways to control code emission, that are not usually available in standard macro systems; in general these subjects are considered separate, except when open implementations are explicitly brought up.
- Growing Languages with Metamorphic Syntax Macros describes a syntax macro language with interesting properties and generality.
- Some LL1 posts which offer some useful advice about when and how to use macros. Perhaps these will coalesce into a proper set of published principles soon.
- Macros as Multi-Stage Computations: Type-Safe, Generative, Binding Macros in MacroML
- Maya: a multi-dispatch macro system for Java written in Kawa.
- Semantically-Sensitive Macroprocessing.
- Macro by Example.
- First-class Macros Have Types by Alan Bawden.
This page is linked from: C Compiler dlopen VM Continuation-Passing Style FDScript Felix FreshML Lisp PL 101 Scheme Syntax in Lisp Type System