[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding "Non-applicable" Methods



    Date: Fri, 23 Dec 88 11:57:20 PST
    From: David E. Wallace <wallace%hpldew@hplabs.HP.COM>

    The CLOS Spec in Chapters 1 & 2 offers a way to find all applicable
    methods for a given set of arguments, but it doesn't seem to provide
    any way to determine what methods might be applicable to a different
    set of arguments.  What I would like to see is (1): a way to get all
    currently defined methods on a particular generic function, and (2):
    a way to determine, given a method object, what set of arguments
    would select it.  Is there a portable way to do this with the spec
    as it now stands?  If not, is it still possible to submit something
    like this as a cleanup proposal?

The functionality you are asking for is available with simple metaobject
accessors defined in the metaobject protocol.  Using these accessors, it
is possible to find out about the methods of a generic function, and the
class precedence list of classes.  Given that information, you can write
the particular functionality you are asking for.

The accessors in question are:

GENERIC-FUNCTION-METHODS (generic-function)      [Generic Function]

Given a generic function object, this returns a list of the methods on
that generic function.  The elements of this list are method objects.


METHOD-SPECIALIZERS (method)                      [Generic Function]

Given a method object, this returns a list of the method's specializers.
The elements of this list are class objects, or lists of the form (EQL
<object>).

CLASS-PRECEDENCE-LIST (class)                     [Generic Function]

Given a class, this returns the class precedence list of the class.  The
elements of this list are class objects.

Each of these exist in the current PCL with the exception that
method-specializers is currently called method-type-specifiers.
-------