Skip to main content

14.5 Common Problems Using Macros

Macro expansion can have counterintuitive consequences. This section describes some important consequences that can lead to trouble, and rules to follow to avoid trouble.

Wrong Time  Do the work in the expansion, not in the macro.
Argument Evaluation  The expansion should evaluate each macro arg once.
Surprising Local Vars  Local variable bindings in the expansion require special care.
Eval During Expansion  Don’t evaluate them; put them in the expansion.
Repeated Expansion  Avoid depending on how many times expansion is done.