DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(goops.info.gz) Class Definition

Info Catalog (goops.info.gz) MOP Specification (goops.info.gz) Instance Creation
 
 Class Definition
 ================
 
 `define-class' (syntax)
 
    * `class' (syntax)
 
         * `make-class' (procedure)
 
              * `make METACLASS ...' (generic)
 
                METACLASS is the metaclass of the class being defined,
                either taken from the `#:metaclass' class option or
                computed by `ensure-metaclass'.  The applied method must
                create and return the fully initialized class metaobject
                for the new class definition.
 
 
    * `class-redefinition OLD-CLASS NEW-CLASS' (generic)
 
      `define-class' calls `class-redefinition' if the variable
      specified by its first argument already held a GOOPS class
      definition.  OLD-CLASS and NEW-CLASS are the old and new class
      metaobjects.  The applied method should perform whatever is
      necessary to handle the redefinition, and should return the class
      metaobject that is to be bound to `define-class''s variable.  The
      default class redefinition protocol is described in  Class
      Redefinition.
 
 The `(make METACLASS ...)' invocation above will create an class
 metaobject with metaclass METACLASS.  By default, this metaobject will
 be initialized by the `initialize' method that is specialized for
 instances of type `<class>'.
 
 `initialize <class> INITARGS' (method)
 
    * `compute-cpl CLASS' (generic)
 
      The applied method should compute and return the class precedence
      list for CLASS as a list of class metaobjects.  When `compute-cpl'
      is called, the following CLASS metaobject slots have all been
      initialized: `name', `direct-supers', `direct-slots',
      `direct-subclasses' (empty), `direct-methods'.  The value returned
      by `compute-cpl' will be stored in the `cpl' slot.
 
    * `compute-slots CLASS' (generic)
 
      The applied method should compute and return the slots (union of
      direct and inherited) for CLASS as a list of slot definitions.
      When `compute-slots' is called, all the CLASS metaobject slots
      mentioned for `compute-cpl' have been initialized, plus the
      following: `cpl', `redefined' (`#f'), `environment'.  The value
      returned by `compute-slots' will be stored in the `slots' slot.
 
    * `compute-get-n-set CLASS SLOT-DEF' (generic)
 
      `initialize' calls `compute-get-n-set' for each slot computed by
      `compute-slots'.  The applied method should compute and return a
      pair of closures that, respectively, get and set the value of the
      specified slot.  The get closure should have arity 1 and expect a
      single argument that is the instance whose slot value is to be
      retrieved.  The set closure should have arity 2 and expect two
      arguments, where the first argument is the instance whose slot
      value is to be set and the second argument is the new value for
      that slot.  The closures should be returned in a two element list:
      `(list GET SET)'.
 
      The closures returned by `compute-get-n-set' are stored as part of
      the value of the CLASS metaobject's `getters-n-setters' slot.
      Specifically, the value of this slot is a list with the same
      number of elements as there are slots in the class, and each
      element looks either like
 
           `(SLOT-NAME-SYMBOL INIT-FUNCTION . INDEX)'
 
      or like
 
           `(SLOT-NAME-SYMBOL INIT-FUNCTION GET SET)'
 
      Where the get and set closures are replaced by INDEX, the slot is
      an instance slot and INDEX is the slot's index in the underlying
      structure: GOOPS knows how to get and set the value of such slots
      and so does not need specially constructed get and set closures.
      Otherwise, GET and SET are the closures returned by
      `compute-get-n-set'.
 
      The structure of the `getters-n-setters' slot value is important
      when understanding the next customizable generic functions that
      `initialize' calls...
 
    * `compute-getter-method CLASS GNS' (generic)
 
      `initialize' calls `compute-getter-method' for each of the class's
      slots (as determined by `compute-slots') that includes a
      `#:getter' or `#:accessor' slot option.  GNS is the element of the
      CLASS metaobject's `getters-n-setters' slot that specifies how the
      slot in question is referenced and set, as described above under
      `compute-get-n-set'.  The applied method should create and return
      a method that is specialized for instances of type CLASS and uses
      the get closure to retrieve the slot's value.  [ *fixme  Need to
      insert something here about checking that the value is not
      unbound. ] `initialize' uses `add-method!' to add the returned
      method to the generic function named by the slot definition's
      `#:getter' or `#:accessor' option.
 
    * `compute-setter-method CLASS GNS' (generic)
 
      `compute-setter-method' is invoked with the same arguments as
      `compute-getter-method', for each of the class's slots that
      includes a `#:setter' or `#:accessor' slot option.  The applied
      method should create and return a method that is specialized for
      instances of type CLASS and uses the set closure to set the slot's
      value.  `initialize' then uses `add-method!' to add the returned
      method to the generic function named by the slot definition's
      `#:setter' or `#:accessor' option.
 
Info Catalog (goops.info.gz) MOP Specification (goops.info.gz) Instance Creation
automatically generated byinfo2html