Common Lisp the Language, 2nd Edition
Next: Initialize-Instance
Up: Object Creation and
Previous: Rules for
Initialization
The generic function shared-initialize
is used to fill the
slots of an instance using initialization arguments and
:initform
forms when an instance is created, when an
instance is re-initialized, when an instance is updated to conform to a
redefined class, and when an instance is updated to conform to a
different class. It uses standard method combination. It takes the
following arguments: the instance to be initialized, a specification of
a set of names of slots accessible in that instance, and any number of
initialization arguments. The arguments after the first two must form an
initialization argument list.
The second argument to shared-initialize
may be one of
the following:
nil
, which specifies the empty set of slot
names.t
, which specifies the set of all
of the slots.There is a system-supplied primary method for
shared-initialize
whose first parameter specializer is the
class standard-object
. This method behaves as follows on
each slot, whether shared or local:
shared-initialize
.:initform
forms. For any such slot that has an :initform
form, that
form is evaluated in the lexical environment of its defining
defclass
form and the result is stored into the slot. For
example, if a :before
method stores a value in the slot,
the :initform
form will not be used to supply a value for
the slot. If the second argument specifies a name that does not
correspond to any slots accessible in the instance, the results are
unspecified.The generic function shared-initialize
is called by the
system-supplied primary methods for the generic functions
initialize-instance
, reinitialize-instance
,
update-instance-for-different-class
, and
update-instance-for-redefined-class
. Thus methods can be
written for shared-initialize
to specify actions that
should be taken in all of these contexts.
Next: Initialize-Instance
Up: Object Creation and
Previous: Rules for
Initialization
AI.Repository@cs.cmu.edu