(goops.info.gz) Changing the Class of an Instance
Info Catalog
(goops.info.gz) Redefining a Class
(goops.info.gz) Reference Manual
(goops.info.gz) Introspection
Changing the Class of an Instance
=================================
You can change the class of an existing instance by invoking the
generic function `change-class' with two arguments: the instance and
the new class.
- generic: change-class
The default method for `change-class' decides how to implement the
change of class by looking at the slot definitions for the instance's
existing class and for the new class. If the new class has slots with
the same name as slots in the existing class, the values for those slots
are preserved. Slots that are present only in the existing class are
discarded. Slots that are present only in the new class are initialized
using the corresponding slot definition's init function (
slot-init-function Classes.).
- method: change-class (obj <object>) (new <class>)
Modify instance OBJ to make it an instance of class NEW.
The value of each of OBJ's slots is preserved only if a similarly
named slot exists in NEW; any other slot values are discarded.
The slots in NEW that do not correspond to any of OBJ's
pre-existing slots are initialized according to NEW's slot
definitions' init functions.
Customized change of class behaviour can be implemented by defining
`change-class' methods that are specialized either by the class of the
instances to be modified or by the metaclass of the new class.
When a class is redefined ( Redefining a Class), and the default
class redefinition behaviour is not overridden, GOOPS (eventually)
invokes the `change-class' generic function for each existing instance
of the redefined class.
Info Catalog
(goops.info.gz) Redefining a Class
(goops.info.gz) Reference Manual
(goops.info.gz) Introspection
automatically generated byinfo2html