Previous: , Up: Macros   [Contents][Index]

5.10.4 Compiling Macros

Although it may seem odd that macros return a form to produce a result and not simply the result itself, this is actually their most important feature. It allows the expansion and the evaluation of the expansion to occur at different times.

The Lisp compiler makes use of this; when it comes across a macro call in a form it is compiling it uses the macroexpand function to produce the expansion of that form. This expansion is then compiled straight into the object code. Obviously this is good for performance (why evaluate the expansion every time it is needed when once will do?).

Some rules do need to be observed to make this work properly:

Note however, that the Librep compiler does allow macros to be used before they are defined (two passes are made through the source file).