Version: 4.2.1

3.2 Subforms with Expansion Contexts

Synopsis: How to create expansion contexts for special subforms.

Examples: class, public, and define/public

Ordinary macros extend the language with new expression and definition forms. Looking at it from the other direction, we can say that expression and definitions contexts are expansion contexts, positions where macro expansion occurs.

Macros can create new expansion contexts that accept other syntactic forms besides just expressions and definitions – for example, class-level declarations. That makes it useful to write macros that expand into special subforms.

For example, the class macro has a public special subform, and the define/public macro expands into a definition together with a public subform.

Use local-expand to permit abstraction over special subforms.