Lisp Macros

Summary: Lisp macros are different than macros in other languages, and have the ability to define fundamentally different languages to solve specific problems.
up
prev next

search
site map
navigate
about

<*LISP*>
<*learning*>
<*applications*>
<*tools*>
<*community*>
<*references*>
<*systems*>
<*related*>

top-level
syntax
evaluation
environment
objects
dynamic
typing
memory
macros
performance
3GL
history
compare
combine

At some point in the compilation or evaluation process, Lisp programs are represented by list data. Lisp provides many tools for examining and constructing list data. The Common Lisp macro facility allows programmers to use these tools to write small programs that translate one list representation of a program into another.

The Lisp system will automatically make use of any such macros that the programmer defines. The macros can be defined to operate on lists representing complex Lisp expressions, or on individual symbols that would otherwise represent variable references. The macros can have global scope, or be active only during a certain region of the program code. The system will automatically invoke any required additional macros which are introduced by the translated results.

Allowing the programmer to use the entire Common Lisp language in defining programs to translate one program expression into another is very different than the simple character-based text substitution found in other languages.

Another feature is that there are no statements in Common Lisp, only nested lists of program expressions. This makes it easy to define a single macro that can check the syntax of its own usage and be used in a variety of situations. It is the lack of this ability in C that has lead to complicated template utilities in C++. Lisp macros are a more flexible, uniform and easier to use approach.

The macro mechanism allows small (or complex) utilties for solving specific problems to be defined by the programmer, and then used at will.