From: Liam Healy
Subject: Finding an applicable method and find-method
Date: 
Message-ID: <51bubzcuct.fsf@eutaw.nrl.navy.mil>
I would like to find the applicable method given arguments of the
specified classes.  e.g. if 'subfoo is a subclass of 'foo, and there
is a method for 'foo no explicit method for 'subfoo,
(find-method #'fn nil (list 'subfoo) nil)
comes up with nil, not the method
(find-method #'fn nil (list 'foo) nil).
Is there an easy way to get the method that would be applied for the
argument classes given?


-- 
Liam Healy 
··········@nrl.navy.mil 
(If mailing, type in this address, don't use reply function; address
in header is bogus to stop spam.)
From: Howard R. Stearns
Subject: Re: Finding an applicable method and find-method
Date: 
Message-ID: <32B580D2.59E2B600@elwoodcorp.com>
Liam Healy wrote:
> 
> I would like to find the applicable method given arguments of the
> specified classes.  e.g. if 'subfoo is a subclass of 'foo, and there
> is a method for 'foo no explicit method for 'subfoo,
> (find-method #'fn nil (list 'subfoo) nil)
> comes up with nil, not the method
> (find-method #'fn nil (list 'foo) nil).
> Is there an easy way to get the method that would be applied for the
> argument classes given?
> 
> --
> Liam Healy
> ··········@nrl.navy.mil
> (If mailing, type in this address, don't use reply function; address
> in header is bogus to stop spam.)

Find-method is intentended to find a particular (i.e. one) method.  That
is why it takes the METHOD's specializers as arguments, rather than the
classes of some CALL's actual arguments.  A call with a particular set
of arguments might have SEVERAL applicable methods.

ANSI defines a generic function, compute-applicable-methods, that
returns all applicable methods for a particular sets of arguments (not
classes of arguments).

The MetaObject Protocol (MOP) defines a generic function,
compute-applicable-methods-using-classes, that returns all applicable
methods for a set of clasess representing the arguments -- iff it is
possible to completely determine the ordered list of applicable methods
based only the supplied classes.  (A second returned value indicates
whether this was the case.)

Eql specializers can keep compute-applicable-methods-using-classes from
returning a true second value.

Of course, your platform might not fully support the MOP, as it is not
ANSI.  For more information, see:

 The Art of the Metaobject Protocol, by Kiczales, des Rivieres, and
Bobrow, MIT Press, 1991.  ISBN 0-262-11158-6 (hc) 0-262-61074-4 (pbk)