| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
4.1 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
#:metaclassclass option or computed byensure-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-classcallsclass-redefinitionif 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 todefine-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-cplis called, the following class metaobject slots have all been initialized:name,direct-supers,direct-slots,direct-subclasses(empty),direct-methods. The value returned bycompute-cplwill be stored in thecplslot. -
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-slotsis called, all the class metaobject slots mentioned forcompute-cplhave been initialized, plus the following:cpl,redefined(#f),environment. The value returned bycompute-slotswill be stored in theslotsslot. -
compute-get-n-set class slot-def(generic)initializecallscompute-get-n-setfor each slot computed bycompute-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-setare stored as part of the value of the class metaobject'sgetters-n-settersslot. 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-settersslot value is important when understanding the next customizable generic functions thatinitializecalls… -
compute-getter-method class gns(generic)initializecallscompute-getter-methodfor each of the class's slots (as determined bycompute-slots) that includes a#:getteror#:accessorslot option. gns is the element of the class metaobject'sgetters-n-settersslot that specifies how the slot in question is referenced and set, as described above undercompute-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. ]initializeusesadd-method!to add the returned method to the generic function named by the slot definition's#:getteror#:accessoroption. -
compute-setter-method class gns(generic)compute-setter-methodis invoked with the same arguments ascompute-getter-method, for each of the class's slots that includes a#:setteror#:accessorslot 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.initializethen usesadd-method!to add the returned method to the generic function named by the slot definition's#:setteror#:accessoroption.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
