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

Lexical environment of slot default initial value forms



DLW points out that we should specify in what environment default
initial value forms for slots are evaluated, if/when they get evaluated.
This includes both the lexical environment and the dynamic environment.
Note that the lexical environment refers both to variables and to functions
(and to go tags, blocks, and declarations, if someone was so untasteful
as to do a non-local-go out of a default initial value form!); free variables
are rare in these forms, but free functions are common.

We discussed this and concluded that the lexical environment should be the
lexical environment where the form originally appeared, i.e. the lexical
environment in which defclass was evaluated, and the dynamic environment
should be the one in effect at the time the form is evaluated.  There are
other suggestions, but they aren't as good.  Happily, this is the same thing
that CLtL (p.309) says for defstruct slot initialization forms.

It can be difficult to get the correct lexical environment without any bugs
and simultaneously maximize efficiency, especially when using :constructor,
but I think it's more important for the language to have a clean definition.
If some implementations have bugs that's their business.

The good news is that most often these forms are constants, so the environments
don't matter.  An implementation can optimize that case easily enough.