Package: closer-mop

Generic Function ensure-class-using-class

Lambda List

ensure-class-using-class (class name &rest args &allow-other-keys)

Arguments

The class argument is a class metaobject or nil.
The name argument is a class name.
The :metaclass argument is a class metaobject class or a class metaobject class name. If this argument is not supplied, it defaults to the class named standard-class. If a class name is supplied, it is interpreted as the class with that name. If a class name is supplied, but there is no such class, an error is signaled.
The :direct-superclasses argument is a list of which each element is a class metaobject or a class name. An error is signaled if this argument is not a proper list.
For the interpretation of additional keyword arguments, see "Initialization of Class Metaobjects".

Return Value

The result is a class metaobject.

Details

This generic function is called to define or modify the definition of a named class. It is called by the ensure-class function. It can also be called directly.

The first step performed by this generic function is to compute the set of initialization arguments which will be used to create or reinitialize the named class. The initialization arguments are computed from the full set of keyword arguments received by this generic function as follows:
  • The :metaclass argument is not included in the initialization arguments.
  • If the :direct-superclasses argument was received by this generic function, it is converted into a list of class metaobjects. This conversion does not affect the structure of the supplied :direct-superclasses argument. For each element in the :direct-superclasses argument:
    • If the element is a class metaobject, that class metaobject is used.
    • If the element names a class, that class metaobject is used.
    • Otherwise an instance of the class forward-referenced-class is created and used. The proper name of the newly created forward referenced class metaobject is set to name.
  • All other keyword arguments are included directly in the initialization arguments.
If the class argument is nil, a new class metaobject is created by calling the make-instance generic function with the value of the :metaclass argument as its first argument, and the previously computed initialization arguments. The proper name of the newly created class metaobject is set to name. The newly created class metaobject is returned.

If the class argument is a forward referenced class, change-class is called to change its class to the value specified by the :metaclass argument. The class metaobject is then reinitialized with the previously initialization arguments. (This is a documented violation of the general constraint that change-class not be used with class metaobjects.)

If the class of the class argument is not the same as the class specified by the :metaclass argument, an error is signaled.

Otherwise, the class metaobject class is redefined by calling the reinitialize-instance generic function with class and the initialization arguments. The class argument is then returned.

Methods

ensure-class-using-class ((class class) name &key :metaclass :direct-superclasses &allow-other-keys)
This method implements the behavior of the generic function in the case where the class argument is a class.

This method can be overridden.


ensure-class-using-class ((class forward-referenced-class) name &key :metaclass :direct-superclasses &allow-other-keys)
This method implements the behavior of the generic function in the case where the class argument is a forward referenced class.


ensure-class-using-class ((class null) name &key :metaclass :direct-superclasses &allow-other-keys)
This method implements the behavior of the generic function in the case where the class argument is nil.