DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(goops.info.gz) Customizing Class Redefinition

Info Catalog (goops.info.gz) Default Class Redefinition Behaviour (goops.info.gz) Redefining a Class
 
 Customizing Class Redefinition
 ------------------------------
 
 When `define-class' notices that a class is being redefined, it
 constructs the new class metaobject as usual, and then invokes the
 `class-redefinition' generic function with the old and new classes as
 arguments.  Therefore, if the old or new classes have metaclasses other
 than the default `<class>', class redefinition behaviour can be
 customized by defining a `class-redefinition' method that is
 specialized for the relevant metaclasses.
 
  - generic: class-redefinition
      Handle the class redefinition from OLD-CLASS to NEW-CLASS, and
      return the new class metaobject that should be bound to the
      variable specified by `define-class''s first argument.
 
  - method: class-redefinition (old-class <class>) (new-class <class>)
      Implements GOOPS' default class redefinition behaviour, as
      described in  Default Class Redefinition Behaviour.
      Returns the metaobject for the new class definition.
 
 An alternative class redefinition strategy could be to leave all
 existing instances as instances of the old class, but accepting that the
 old class is now "nameless", since its name has been taken over by the
 new definition.  In this strategy, any existing subclasses could also
 be left as they are, on the understanding that they inherit from a
 nameless superclass.
 
 This strategy is easily implemented in GOOPS, by defining a new
 metaclass, that will be used as the metaclass for all classes to which
 the strategy should apply, and then defining a `class-redefinition'
 method that is specialized for this metaclass:
 
      (define-class <can-be-nameless> (<class>))
      
      (define-method (class-redefinition (old <can-be-nameless>) (new <class>))
        new)
 
 When customization can be as easy as this, aren't you glad that GOOPS
 implements the far more difficult strategy as its default!
 
 Finally, note that, if `class-redefinition' itself is not customized,
 the default `class-redefinition' method invokes three further generic
 functions that could be individually customized:
 
    * (remove-class-accessors! OLD-CLASS)
 
    * (update-direct-method! METHOD OLD-CLASS NEW-CLASS)
 
    * (update-direct-subclass! SUBCLASS OLD-CLASS NEW-CLASS)
 
 and the default methods for these generic functions invoke further
 generic functions, and so on...  The detailed protocol for all of these
 is described in  MOP Specification.
 
Info Catalog (goops.info.gz) Default Class Redefinition Behaviour (goops.info.gz) Redefining a Class
automatically generated byinfo2html