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

Redefining Classes

Redefining Classes

When a defclass form is evaluated and a class with the given name
already exists, the existing class is redefined.  This may also cause
some of the subclasses of the redefined class to also be redefined.
Classes my also be redefined using the metaobject protocol -- see the
functions add-named-class and update-class.  

For instances of standard-class, redefining a class modifies the
existing class object to reflect the new class definition; it does not
create a new class object for the class.  Any method created by an
:accessor, :reader,  specified by the old  defclass form is removed from
the corresponding generic function unless that same method is specified
by the new defclass form. 

If the redefinition of a class causes the structure of its instances to
be different, and the class has instances, then the generic function
make-instances-obsolete is called. The function make-instances-obsolete
takes as its one argument the class to be redefined.  This invocation
captures the state of the class before redefinition, and marks all
existing instances of the class as obsolete.  Such instances will be
updated to the new structure determined by the class redefinition.  This
updating will be done in such a way that users will never see an
instance with the obsolete structure.  THIS IS ONLY GUARANTEED TO BE

     make-instances-obsolete class      (generic-function)

Obsolete instance updating is done in two stages:  

1) The system creates a property list that captures the slot names and
values of all the slots of the obsolete instance.  It then transforms
the structure of the instance, so that it conforms to the current class
definition.  All the slots of this transformed instance are
uninitialized.  This first stage cannot be seen by user programs. 

2) The generic function update-obsolete-instance is called.  Its
arguments are the transformed instance, and the property list of
slot-names and values corresponding to the state of the obsolete
instance.  Its contract is to do appropriate updating of the instance,
using the values from the obsolete slots.

Because update-obsolete-instance is user code, its operation can be seen
by the user; but the model that CLOS supports is that as far as the user
can tell, all the existing instances of a class are updated as soon as
the class redefinition happens.  This implies that the user must define
a method for update-obsolete-instance before redefining a class.
Implementations are free to delay the conversion of existing instances
(for example, to method call or slot access time), but users should
never be able to see the untransformed instance.

   update-obsolete-instance instance property-list  (generic-function)

The method on update-obsolete-instance defined on the class Object does
the following:

1) for each instance slot in current definition of class, if its
slot-name appears in the property list, the value corresponding to the