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

EVAL-WHEN buried inside forms.

I agree that CLTL doesn't adequately specify the semantics of
non-top-level EVAL-WHEN's.  This isn't surprising, since there
evidently wasn't any attempt to.  Multiple compile-time evaluation is
a common characteristic of incorrect eval-when implementations, even
when they don't attempt to handle non-top-level occurrences.

In the Spice Lisp compiler, the Stuff in your example is only
evaluated once.  When the compiler initially evaluates the outer
EVAL-WHEN, it binds a special indicating that the code within it has
already been evaluated.  The compiler doesn't evaluate non-top-level
EVAL-WHEN's when this flag is true.  The flag gets bound to NIL when
the compiler encounters a form which isn't wasn't evaled, such as an

The compiler also needs to communicate with the interpreter so that
when the compiler evals a form, the interpreter evaluates EVAL-WHEN
COMPILE's which it would otherwise ignore.