. navigate
Navigate
XREF    Page 10 left arrow
x
right arrow Page 12    XREF
XREF








LISP Pointers
Volume I, Number 1
April-May 1987



XREF
page 11









Prev Article               Start of This Article                Next Article



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 Hnal caveats:

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 machines.




References

[1]  Steele, Guy Lewis Jr. Common Lisp: The Language. Digital Press, 1984.

[2]  Teitelman, Warren. IN TERLISP Reference Manual. Xerox Palo Alto Research Center, 1978.

[3]  Digital Equipment Corporation. VAX LISP/ VMS User's Guide. Maynard, Massachusetts, May 1986.

[4]  Moon, David, Stallman, Richard, and Weinreb, Daniel. LISP Machine Manual, Fifth Edi- tion. MIT Artificial Intelligence Lab, 1983.

[5]  Symbolics, Inc. Reference Guide to Symbolics-Lisp, Cambridge, Massachusetts, March, 1985.


*****************
13    *package* and *readtable* are temporarily bound.

14    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.


Page Left left arrow         
x
right arrow Page Right
Vol. I, No. 1
Table of Contents




Home   Favorites   Computers   Map

IME logo Copyright © 2009, Mary S. Van Deusen