Go to the first, previous, next, last section, table of contents.


Evaluation During Compilation

These features permit you to write code to be evaluated during compilation of a program.

Special Form: eval-and-compile body
This form marks body to be evaluated both when you compile the containing code and when you run it (whether compiled or not).

You can get a similar result by putting body in a separate file and referring to that file with require. That method is preferable when body is large.

Special Form: eval-when-compile body
This form marks body to be evaluated at compile time but not when the compiled program is loaded. The result of evaluation by the compiler becomes a constant which appears in the compiled program. If you load the source file, rather than compiling it, body is evaluated normally.

Common Lisp Note: At top level, this is analogous to the Common Lisp idiom (eval-when (compile eval) ...). Elsewhere, the Common Lisp `#.' reader macro (but not when interpreting) is closer to what eval-when-compile does.


Go to the first, previous, next, last section, table of contents.