Function ensure-generic-function

Syntax:

ensure-generic-function function-name &key argument-precedence-order declare documentation environment generic-function-class lambda-list method-class method-combination generic-function

Arguments and Values:

function-name—a function name.

The keyword arguments correspond to the option arguments of defgeneric, except that the :method-class and :generic-function-class arguments can be class objects as well as names.

!!! What's a method combination object??method-combination—method combination object.

environment—the same as the &environment argument to macro expansion functions and is used to distinguish between compile-time and run-time environments. Barmar said (and I agree) that this just doesn't belong here. \issue{MACRO-ENVIRONMENT-EXTENT:DYNAMIC} The \keyref{environment} argument has \term{dynamic extent}; the consequences are undefined if the \keyref{environment} argument is referred to outside the \term{dynamic extent} of the macro expansion function. \endissue{MACRO-ENVIRONMENT-EXTENT:DYNAMIC}

Editor: KMP: What about documentation. Missing from this arguments enumeration, and confusing in description below.!!! generic-function—a generic function object.

Description:

The function ensure-generic-function is used to define a globally named generic function with no methods or to specify or modify options and declarations that pertain to a globally named generic function as a whole.

!!! This used to refer to FBOUNDP but I changed it to use "fbound". The question is, why is it looking in the global env if an environment argument was passed.If function-name is not fbound in the global environment, a new generic function is created. !!! Rewrite in terms of function cell contents?If (fdefinition function-name) is an ordinary function, a macro, or a special operator, an error is signaled.

If function-name is a list, it must be of the form (setf symbol). If function-name specifies a generic function that has a different value for any of the following arguments, the generic function is modified to have the new value: :argument-precedence-order, :declare, :documentation, :method-combination.

If function-name specifies a generic function that has a different value for the :lambda-list argument, and the new value is congruent with the lambda lists of all existing methods or there are no methods, the value is changed; otherwise an error is signaled.

!!! Barmar: What does this part about "new generic function class is compatible with the old" mean?If function-name specifies a generic function that has a different value for the :generic-function-class argument and if the new generic function class is compatible with the old, change-class is called to change the class of the generic function; otherwise an error is signaled.

If function-name specifies a generic function that has a different value for the :method-class argument, the value is changed, but any existing methods are not changed.

Examples:

None.

Affected By:

Existing function binding of function-name.

Exceptional Situations:

If (fdefinition function-name) is an ordinary function, a macro, or a special operator, an error of type error is signaled.

If function-name specifies a generic function that has a different value for the :lambda-list argument, and the new value is not congruent with the lambda list of any existing method, an error of type error is signaled.

If function-name specifies a generic function that has a different value for the :generic-function-class argument and if the new generic function class not is compatible with the old, an error of type error is signaled.

See Also:

defgeneric

Notes:

None.