Hello.
I have a question to AMOP, Page 204 (Initialization of Slot Definition
Metaobjects, see <http://www.lisp.org/mop/dictionary.html#Initialization>)
The :initfunction argument is a function of zero arguments (?) which,
when called, evaluates the :initform in the appropriate lexical
environment. The :initfunction argument defaults to false. An error is
signaled if the :initfunction argument is supplied, but the :initform
argument is not supplied.
Should this read "of one argument"? Or should initform and initfunction be
independent?
Nicolas.
Nicolas Neuss <·······@iwr.uni-heidelberg.de> writes:
> The :initfunction argument is a function of zero arguments (?) which,
> when called, evaluates the :initform in the appropriate lexical
> environment. The :initfunction argument defaults to false. An error is
> signaled if the :initfunction argument is supplied, but the :initform
> argument is not supplied.
>
> Should this read "of one argument"? Or should initform and
> initfunction be independent?
No, zero arguments is correct, because the initfunction is a closure
that closes over all the information it needs. It'll be something like
this:
:initform 123
:intifunction (lambda () 123)
Or
(let ((lexically-other 'blargh))
...
:initform (compute 'foo 42 (1+ *something*) (1- lexically-other))
:initfunction (lambda ()
(compute 'foo 42 (1+ *something*)
(1- lexically-other)))
...)
So they are not independent, the form is just the symbolic version of
the intifunction. I'm not actually sure it's really required/necessary
to keep the (symbolic) initform around.
--
Frode Vatvedt Fjeld
Frode Vatvedt Fjeld wrote:
> So they are not independent, the form is just the symbolic version of
> the intifunction. I'm not actually sure it's really required/necessary
> to keep the (symbolic) initform around.
I don't think so because in general, the initform doesn't provide enough
information to recreate the correct initialization value. I guess it's
main purpose is to provide some form of documentation.
Pascal
--
Tyler: "How's that working out for you?"
Jack: "Great."
Tyler: "Keep it up, then."