[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13. Macros

Macros enable you to define new control constructs and other language features. A macro is defined much like a function, but instead of telling how to compute a value, it tells how to compute another Lisp expression which will in turn compute the value. We call this expression the expansion of the macro.

Macros can do this because they operate on the unevaluated expressions for the arguments, not on the argument values as functions do. They can therefore construct an expansion containing these argument expressions or parts of them.

If you are using a macro to do something an ordinary function could do, just for the sake of speed, consider using an inline function instead. See section 12.9 Inline Functions.

13.1 A Simple Example of a Macro  A basic example.
13.2 Expansion of a Macro Call  How, when and why macros are expanded.
13.3 Macros and Byte Compilation  How macros are expanded by the compiler.
13.4 Defining Macros  How to write a macro definition.
13.5 Backquote  Easier construction of list structure.
13.6 Common Problems Using Macros  Don't evaluate the macro arguments too many times. Don't hide the user's variables.



This document was generated on May 2, 2002 using texi2html