[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Understanding Method Combination.
Date: Wed, 15 Mar 89 12:02:44 PST
From: James Rice <email@example.com>
As far as I know the MOP doesn't provide a way for a tool to find out
about combined methods in a way in which the user/environment tools
might be interested.
The MOP provides this behavior, and PCL implements a version of it. In
fact, much of this is specified in chapters 1 and 2.
COMPUTE-APPLICABLE-METHODS (generic-function args)
This accepts a generic function and a list of arguments and
returns the ordered list of methods applicable to those arguments.
COMPUTE-EFFECTIVE-METHOD-BODY (generic-function methods)
This takes a generic function and a list of methods and returns
the `effective method body' of the effective method. So, this
does the actual method combination. Note that the arguments to
this will change slightly in a future release.
(defclass c1 () ())
(defclass c2 () ())
(defclass c3 (c1 c2) ())
(defmethod foo ((o c1)) ())
(defmethod foo :before ((o c2)) ())
(defmethod foo :before ((o c3)) ())
(defmethod foo :after ((o c1)) ())
(compute-applicable-methods #'foo (list (*make-instance 'c3)))
==> (#<Standard-Method FOO :BEFORE (C3) 200020005>
#<Standard-Method FOO :AFTER (C1) 101000761>
#<Standard-Method FOO (C1) 200020043>
#<Standard-Method FOO :BEFORE (C2) 200020017>)
(compute-effective-method-body #'foo *)
==> (PROGN (CALL-METHOD #<Standard-Method FOO :BEFORE (C3) 200020005> NIL)
(CALL-METHOD #<Standard-Method FOO :BEFORE (C2) 200020017> NIL)
(MULTIPLE-VALUE-PROG1 (CALL-METHOD #<Standard-Method FOO (C1) 200020043> NIL)
(CALL-METHOD #<Standard-Method FOO :AFTER (C1) 101000761> NIL)))
Which I believe is what you are asking for.
In typing this message I discovered that there is a slight bug in
COMPUTE-APPLICABLE-METHODS. You have to actually call the generic
function once before COMPUTE-APPLICABLE-METHODS will work properly.
This is now on my to fix list.