[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

EVAL-WHEN: question about intent



Despite Guy Steele's improvements, I believe the definition of EVAL-WHEN in
the published definition is still fuzzy and the intent is not clear.  The
purpose of this message is to outline the nature of this fuzziness and request
opinions from designers and users regarding use of EVAL-WHEN.  The issue
raised by this message is distinct from the issue I raised in a recent message
(to which I have not seen any replies).

--------------------------------------------------------------------------------

There are two different, but related characteristics that one might want to
control using EVAL-WHEN.

Characteristic 1: Direct Evaluation vs. Making a Compiled File

  A.  Making a "compiled" file involves processing a collection of
      forms and producing a file that later can be loaded to achieve the
      effect of evaluating those forms.  In this case, there are two clearly
      distinct "times" (when the file is being made and when it is being
      loaded) and potentially two distinct environments.  Note that making a
      "compiled file" need not involve the generation of "machine code",
      although it is presumed to involve "reading the file" (and invoking
      readmacros) and "expanding macros", two activities where the Common Lisp
      manual explicitly mentions that EVAL-WHEN may be required.

  B.  The alternative is "direct evaluation" (for side-effect and
      result).  As stated on page 321, direct evaluation can be performed by
      an interpreter, or by compiling the form into some other representation
      (such as "machine code") and then interpreting this representation
      (perhaps by "hardware").  In this case, there is only one "time" as far
      as the user is concerned, and only one evironment; one may have the
      choice of either "doing it" or "not doing it", but there is no choice as
      to "where it is done", and in no case should "it be done twice".

Characteristic 2: Compilation vs. Interpretation

  A.  In this sense, "compilation" presumably refers to generating
      "machine code", although this notion may be meaningless or ambiguous in
      any particular implementation.  One could argue that even an interpreter
      that uses a preprocessor should be considered to be a "compiler", since
      it transforms the program before executing it.

  B.  The alternative, "interpretation", presumably refers to a 
      technique for evaluation that is not a "compiler", as described above.
      Some implementations may not offer this alternative.

In my view, Characteristic 1 is well defined and useful, but Characteristic 2
is fuzzy to the point of being useless, especially in light of the variety of
possible implementation techniques for evaluation (explicitly permitted on
page 321).

Unfortunately, the definition of EVAL-WHEN refers to both characteristics.
The "COMPILE" and "LOAD" situations for EVAL-WHEN are clearly defined in terms
of compiling a file (Characteristic 1).  However, the definition of the "EVAL"
situation refers to interpreting versus compilation (which sounds like
Characteristic 2).

I do not know what the motivation is for attempting to use EVAL-WHEN to
control what happens during direct evaluation.  PSL does not provide such a
feature: it assumes that regardless of what is desired when making or loading
a compiled file, one always wants to "do it" (once) when directly evaluating.
I would prefer to omit this "EVAL" situation entirely from Common Lisp.

However, it is there, and presumably there are reasons for it.  What are they?
Where would you use this control?  Which characteristic (as described above)
are you attempting to select for when you use EVAL-WHEN?  We must decide which
one it is (it can't be both).

--------------------------------------------------------------------------------

Alan Snyder
hplabs!snyder
-------