[Ecls-list] LOAD-TIME-VALUE and literal object externalisation.
Samium Gromoff
_deepfire at feelingofgreen.ru
Fri Apr 11 10:27:58 UTC 2008
Good day Juan and the list,
I'm back again, with another potentially borderline issue.
My uneducated guess is that the problem is in that the byte-compiled
representation of the LAMBDA, computed during EVAL-WHEN :COMPILE-FILE,
cannot be serialized.
I'm not sure what to make of it, as CLISP, SBCL and GCL
all treat it "okay".
So, here's the test case:
foo.lisp:
(eval-when (:compile-toplevel :load-toplevel :execute)
(defparameter foo (lambda ())))
(load-time-value foo)
deepfire at canopus:~/local/mdb$ ecl -eval '(compile-file "foo.lisp")'
;;; Loading #P"/usr/lib/ecl/cmp.fas"
;;; Loading #P"/usr/lib/ecl/sysfun.lsp"
;;; Compiling foo.lisp.
;;; Compiling (DEFPARAMETER FOO ...).
An error occurred during initialization:
Object #<bytecompiled-function 08091af0> cannot be externalized.
The relevant passages from CLHS seems to be from L-T-V description:
> If a load-time-value expression is processed by compile-file,
> the compiler performs its normal semantic processing (such as
> macro expansion and translation into machine code) on form, but
> arranges for the execution of form to occur at load time
> in a null lexical environment, with the result of this evaluation then
> being treated as a literal object at run time. It is guaranteed that
> the evaluation of form will take place only once when the file is loaded,
> but the order of evaluation with respect to the evaluation of
> top level forms in the file is implementation-dependent.
and from 3.2.2.2 Minimal Compilation:
> * The first argument in a load-time-value form in source code processed
> by compile is evaluated at compile time; in source code processed by
> compile-file, the compiler arranges for it to be evaluated at load time.
> In either case, the result of the evaluation is remembered and used later
> as the value of the load-time-value form at execution time.
Another tricky moment, compiling foo.lisp with :compile-toplevel left out --
(eval-when (:load-toplevel :execute)
(defparameter foo (lambda ())))
(load-time-value foo)
produces the following error:
root at canopus:/home/deepfire/local/mdb# ecl -eval '(compile-file "foo.lisp")'
;;; Loading #P"/usr/lib/ecl/cmp.fas"
;;; Loading #P"/usr/lib/ecl/sysfun.lsp"
;;; Compiling foo.lisp.
;;; Compiling (LOAD-TIME-VALUE FOO).
;;; The form FOO was not evaluated successfully.
;;; You are recommended to compile again.
An error occurred during initialization:
The variable FOO is unbound..
...but it all goes "okay" in sbcl, gcl and clisp.
This might fall under
> but the order of evaluation with respect to the evaluation of
> top level forms in the file is implementation-dependent.
of the L-T-V description, but I'm not sure.
regards, Samium Gromoff
More information about the ecl-devel
mailing list