Next: update-instance-for-different-class, Previous: reinitialize-instance, Up: Objects
standard-object) slot-names &rest initargs
slot-names—a list or
initargs—a list of keyword/value pairs (of initialization argument names and values).
The generic function
shared-initialize is used to fill the
of an instance
using initargs and :initform
forms. It is called 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. The generic function
shared-initialize is called by the
system-supplied primary method for
The generic function
shared-initialize takes the following
arguments: the instance to be initialized, a specification of a set of
slot-names accessible in that instance,
and any number of initargs.
The arguments after the first two must form an
initialization argument list. The system-supplied primary method on
shared-initialize initializes the slots with values according to the
initargs and supplied :initform forms. Slot-names
indicates which slots should be initialized according
to their :initform forms if no initargs are
provided for those slots.
The system-supplied primary method behaves as follows, regardless of whether the slots are local or shared:
defclassform 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.
The slots-names argument specifies the slots that are to be
initialized according to their :initform forms if no
initialization arguments apply. It can be a list of slot names,
which specifies the set of those slot names; or it can be the symbol
which specifies the set of all of the slots.
initialize-instance (Standard Generic Function), reinitialize-instance, update-instance-for-redefined-class, update-instance-for-different-class, slot-boundp, slot-makunbound, Section 7.1 (Object Creation and Initialization), Section 7.1.4 (Rules for Initialization Arguments), Section 7.1.2 (Declaring the Validity of Initialization Arguments)
Initargs are declared as valid by using the :initarg
defclass, or by defining
The keyword name of each keyword parameter
specifier in the lambda list of any method defined on
shared-initialize is declared as a valid initarg
name for all classes for which that method is applicable.
Implementations are permitted to optimize :initform forms that
neither produce nor depend on side effects, by evaluating these forms
and storing them into slots before running any
initialize-instance methods, rather than by handling them in the
initialize-instance method. (This optimization might
be implemented by having the
allocate-instance method copy a
Implementations are permitted to optimize default initial value forms
for initargs associated with slots by not actually
creating the complete initialization argument
list when the only method
that would receive the complete list is the
In this case default initial value forms can be
treated like :initform forms. This optimization has no visible
effects other than a performance improvement.