From: Vassil Nikolov
Subject: questions about the file compilation rules
Date: 
Message-ID: <19980430194710.29174.qmail@nym.alias.net>
I have been pondering over EVAL-WHEN, and I have found a couple
of small things I am not quite sure about.

(1) the compilation and evaluation environments

In CLHS, section 3.2.1 says that `the compilation environment
inherits from the evaluation environment.'  Shouldn't it be
made explicit that this inheritance is dynamic, i.e.
any changes in the evaluation environment during
compilation are immediately reflected in the compilation
environment?  Or does this somehow follow from the rest of
the standard?  I think it is obvious that this is the proper
behaviour; the question is, does the standard unambiguously
state this, or does it follow from common sense only.  For
example, imagine (EVAL-WHEN (:COMPILE-TOPLEVEL) (PROCLAIM ...))
appearing as a top-level form seen by the file compiler.  Then,
imagine that there were a perverse implementation which makes
the effect of that form visible in the compilation environment only
as late as the *next* file compilation.  While brain-damaged, could
it claim to be conforming (to the letter and not the spirit of the
standard)?


(2) EVAL-WHEN examples

(A) There is an example with nested DEFUNs (CLHS, the description
of the special operator EVAL-WHEN; CLtL2, p. 92) where the
expansion of a DEFUN produces, among others, this form:

  (eval-when (:load-toplevel :execute) <form>)

As far as I can see, the above is equivalent to <form>; am
I missing something, and if not, why this redundancy?

(B) Examples which show how to modify the readtable so that
this affects the way the rest of the source file is read wrap
the modifications in

  (eval-when (:compile-toplevel :load-toplevel :execute) ...)

Isn't :LOAD-TOPLEVEL redundant here?  A compiled file is
a binary file (says the CLHS), which should mean (I think)
that at least it does not contain any reader macro syntax;
therefore there is no need to modify the readtable while
loading a compiled file.

* * *

By the way, I came to study EVAL-WHEN in detail in connection
to writing macro-defining macros.  What really helped me
grasp its functionality was the writing of a small code walker
that describes what happens when various EVAL-WHEN forms are
processed.  (If someone happens to be interested, I could
send them the program, not that it's such a great thing.)

Best regards,
Vassil.