Re: [Sbcl-help] EVAL-WHEN question

"Leslie P. Polzer" <sky@...> writes:
> Can someone shed some light on why the use of LOAD/--load
> is not considered to be a :COMPILE-TOPLEVEL or :LOAD-TOPLEVEL
> situation?
It is, if the code has previously been processed by COMPILE-FILE --
but not if it's loaded as source. From the CLHS page for EVAL-WHEN:
The use of the situations :compile-toplevel (or compile) and
:load-toplevel (or load) controls whether and when evaluation occurs
when eval-when appears as a top level form in code processed by
compile-file. See Section 3.2.3 (File Compilation).
Also, from the CLHS page for LOAD, in the context of discussing
loading of a source file:
Note, however, that processing of eval-when forms by load is
controlled by the :execute situation.
I hope that is some light.
Cheers,
Christophe

Thread view

(eval-when (:compile-toplevel :load-toplevel)
(format t "hello~%"))
When this is loaded via LOAD from the REPL or via --load
from the command line no output occurs.
Only adding :EXECUTE will cause evaluation of the inner forms.
Can someone shed some light on why the use of LOAD/--load
is not considered to be a :COMPILE-TOPLEVEL or :LOAD-TOPLEVEL
situation?
Thanks!
Leslie
--
http://www.linkedin.com/in/polzer

"Leslie P. Polzer" <sky@...> writes:
> (eval-when (:compile-toplevel :load-toplevel)
> (format t "hello~%"))
>
> When this is loaded via LOAD from the REPL or via --load
> from the command line no output occurs.
>
> Only adding :EXECUTE will cause evaluation of the inner forms.
>
> Can someone shed some light on why the use of LOAD/--load
> is not considered to be a :COMPILE-TOPLEVEL or :LOAD-TOPLEVEL
> situation?
http://www.lispworks.com/reference/HyperSpec/Body/f_load.htm :
"(Note, however, that processing of eval-when forms by load is
controlled by the :execute situation.)"
http://www.lispworks.com/reference/HyperSpec/Body/s_eval_w.htm :
"The use of the situations :compile-toplevel (or compile) and :load-toplevel (or load) controls whether and when evaluation
occurs when eval-when appears as a top level form in code processed by compile-file."
--
With best regards, Stas.

"Leslie P. Polzer" <sky@...> writes:
> Can someone shed some light on why the use of LOAD/--load
> is not considered to be a :COMPILE-TOPLEVEL or :LOAD-TOPLEVEL
> situation?
It is, if the code has previously been processed by COMPILE-FILE --
but not if it's loaded as source. From the CLHS page for EVAL-WHEN:
The use of the situations :compile-toplevel (or compile) and
:load-toplevel (or load) controls whether and when evaluation occurs
when eval-when appears as a top level form in code processed by
compile-file. See Section 3.2.3 (File Compilation).
Also, from the CLHS page for LOAD, in the context of discussing
loading of a source file:
Note, however, that processing of eval-when forms by load is
controlled by the :execute situation.
I hope that is some light.
Cheers,
Christophe