restored when processing fi1es.13
Top-level macro definitions, defstructs, and defsetfs are
evaluated when they are processed, unless XREF can determine that the current environment
already has a definition under a given name.14
When XREF sees (eval-when (compile . . .) inside), it evaluates what is inside.
XREF expects that the code it analyzes in a given LISP
implementation can be compiled in that implementation environment, so it assumes that it is
safe to evaluate any code that has been marked for evaluation in the compiler context. However,
since compilers may differ in their list of "implicit eval-when" forms, and since system code
may execute differently when called during compilation (e.g., conditioned on a global variable
bound by the compiler), there is no way to guarantee that XREF will produce the same side
effects as the compiler.
The ambiguity over compiler side-effects also sheds light on problems with writing portable
COMMON LISP programs. The previous advice on using eval-when is pertinent, as are these
- Portability Tip 3:
- All macro calls in portable COMMON LISP programs will be expanded;
one should assume that they will be expanded during compilation. Thus anything accessed
by a macro's expander function must be available in the compiler's environment,
which is not guaranteed to be the same as the environment into which files are loaded.
Thus functions and variables accessed by macros should be marked explicitly with the
"(eval-when (compile eval load) that needed by macros, before the accessing
macros are called.
- Portability Tip 4:
- Use some scheme for specifying file dependencies (or at least an ordering
on files) to define packages and reader macros before the code that uses them, macros
before they are called, etc. Use the same scheme for loading and compiling (and XREFing!),
so that side-effects are produced in the same order. require and provide are a start at
such a system, but even a list of file names can suffice for simple systems. For large systems
of files, it is usually worth building a facility like the defsystem utility on ZETALISP
 Steele, Guy Lewis Jr. Common Lisp: The Language. Digital Press, 1984.
 Teitelman, Warren. IN TERLISP Reference Manual. Xerox Palo Alto Research Center, 1978.
 Digital Equipment Corporation. VAX LISP/ VMS User's Guide. Maynard, Massachusetts,
 Moon, David, Stallman, Richard, and Weinreb, Daniel. LISP Machine Manual, Fifth Edi-
tion. MIT Artificial Intelligence Lab, 1983.
 Symbolics, Inc. Reference Guide to Symbolics-Lisp, Cambridge, Massachusetts, March, 1985.
*package* and *readtable* are temporarily bound.
For example, XREF does not evaluate a macro definition if in the current environment the macro is already
defined; this prevents replacing compiled versions with uncompiled versions.