[Ecls-list] Dumping running image
Juan Jose Garcia-Ripoll
jjgarcia at users.sourceforge.net
Sun Mar 11 12:07:48 UTC 2007
2007/3/11, Gabriel Dos Reis <gdr at cs.tamu.edu>:
> | Simply put:
> | (1) Build an program with the macro files. Call it ECL2
> My reading of
> did not suggest to me that the macros will be compiled away, or made
> available in the compiled obejcts, therefore present in in the second
> imageg (ECL2) while processing other files.
> I read your message as suggesting that the macros will be available in
> ECL2. Is that specific to ECL, or is it a standard behaviour?
This is standard. If you have a lisp file that contains a DEFMACRO form as a
toplevel form, then this macro will be compiled and, when loaded afterwards,
it will be available for your program. Try this: write (defmacro foo (a)
`(1+ ,a)) to a file called foo.lsp. Compile it. Exit your image. Load the
compiled file. Is the macro available or not?
The problem is that if you want that macro to be available in the
compilation environment then you would typically enclose the DEFMACRO in
something like (EVAL-WHEN (:COMPILE-TOPLEVEL :LOAD-TOPLEVEL) .... ) so that
the DEFMACRO form is also executed before compilation.
The most complicated case is for macros which are only required when
compiling a particular file, and which are enclosed in a (EVAL-WHEN
(:COMPILE-TOPLEVEL) ...) form. Those macros are evaluated at compilation
time and will be available for compiling the file in which they were found.
What happens with the macro after compilation is not defined by the
standard. Some old build systems can make assumptions which are not
portable: a lisp is perfectly allowed to clean the enviroment from all
macros which were defined by :COMPILE-TOPLEVEL and not loaded afterwards.
Dpto. de Fisica Teorica I, Fac. de CC Fisicas, Universidad Complutense,
Ciudad Universitaria s/n Madrid 28040 (Spain)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ecl-devel