compute-discriminating-function generic-function => function
Arguments and values:
generic-function -- A generic function metaobject.
function -- A function.
This generic function is called to determine the discriminating function for a generic function. When a generic function is called, the installed discriminating function is called with the full set of arguments received by the generic function, and must implement the behavior of calling the generic function: determining the ordered set of applicable methods, determining the effective method, and running the effective method.
To determine the ordered set of applicable methods, the discriminating function first calls compute-applicable-methods-using-classes. If compute-applicable-methods-using-classes returns a second value of false, the discriminating function then calls compute-applicable-methods.
When compute-applicable-methods-using-classes returns a second value of true, the discriminating function is permitted to memoize the first returned value as follows. The discriminating function may reuse the list of applicable methods without calling compute-applicable-methods-using-classes again provided that:
Determination of the effective method is done by calling compute-effective-method When the effective method is run, each method's function is called, and receives as arguments: (i) a list of the arguments to the generic function, and (ii) whatever other arguments are specified in the call-method form indicating that the method should be called. (See make-method-lambda for more information about how method functions are called.)
The generic function compute-discriminating-function is called, and its result installed, by add-method, remove-method, initialize-instance, and reinitialize-instance.
|compute-discriminating-function (generic-function standard-generic-function)|
Since client code is not allowed to define methods on compute-applicable-methods specialized to standard-generic-function, it can be argued that for standard-generic-function, compute-applicable-methods does not have to be called. By relaxing the description of compute-discriminating-function this way, the implementation may also cache results when compute-applicable-methods-using-classes returns nil in its second argument. More generally, whenever some behavior is defined for generic functions when called with only standard classes, since client code is not allowed to alter this behavior in any way, the implementation is often free to choose whatever appropriate implementation technique that has the same affect as the one specified. Notice, however, that any behavior that diverges from what is specified, must not be inherited by client-defined subclasses. Only when arguments are direct instances of specified classes can the implementation arbitrarily choose some other technique. -- Robert Strandh 2017-01-23.