Package: closer-mop

Generic Function ensure-generic-function-using-class

Lambda List

ensure-generic-function-using-class (generic-function fun-name &key environment generic-function-class &allow-other-keys)

Arguments

The generic-function argument is a generic function metaobject or nil.
The function-name argument is a symbol or a list of the form (setf symbol).
The :generic-function-class argument is a class metaobject or a class name. If it is not supplied, it defaults to the class named standard-generic-function. 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.
For the interpretation of additional keyword arguments, see "Initialization of Generic Function Metaobjects".

Return Value

The result is a generic function metaobject.

Details

The generic function ensure-generic-function-using-class is called to define or modify the definition of a globally named generic function. It is called by the ensure-generic-function 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 globally named generic function. These initialization arguments are computed from the full set of keyword arguments received by this generic function as follows:
  • The :generic-function-class argument is not included in the initialization arguments.
  • If the :method-class argument was received by this generic function, it is converted into a class metaobject. This is done by looking up the class name with find-class. If there is no such class, an error is signalled.
  • All other keyword arguments are included directly in the initialization arguments.
If the generic-function argument is nil, an instance of the class specified by the :generic-function-class argument is created by calling make-instance with the previously computed initialization arguments. The function name function-name is set to name the generic function. The newly created generic function metaobject is returned.

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

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

Methods

ensure-generic-function-using-class ((generic-function generic-function) function-name &key :generic-function-class &allow-other-keys)
This method implements the behavior of the generic function in the case where function-name names an existing generic function.

This method can be overridden.


ensure-generic-function-using-class ((generic-function null) function-name &key :generic-function-class &allow-other-keys)
This method implements the behavior of the generic function in the case where function-name names no function, generic function, macro or special form.