[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: methods dispatching ????
- To: firstname.lastname@example.org (mathieu Lafourcade)
- Subject: Re: methods dispatching ????
- From: email@example.com (George Williams)
- Date: Thu, 29 Oct 1992 14:42:29 -0600
- Cc: firstname.lastname@example.org
- In-reply-to: email@example.com (mathieu Lafourcade) "methods dispatching ????" (Oct 28, 6:53pm)
On Oct 28, 6:53pm, mathieu Lafourcade wrote:
> In clos, I define a class C which inherits from two classes : C (A B).
> C has a method M.
> In the call M(C), I want to call alternatively the next-method M(A) or M(C).
> Something like :
> (defmethod M (C)
> (if condition (call-next-method A)
> (call-next-method B)
As I understand it, I don't think you can do this, since you can't
change the set of methods which are considered by call-next-method.
However, you could add a keyword argument to the call via
call-next-method so that the methods on A & B can determine whether they
should do anything. E.g., something like:
(defmethod M ((self A) &KEY situation)
(when (eq situation 'A)
(defmethod M ((self B) &KEY situation)
(when (eq situation 'B)
(defmethod M ((self C) &REST rest &KEY situation)
:situation (if (condition) 'A 'B)
Even if the original generic call to M included a :situation, the C
method's value would override it, since only the first occurrence of a
keyword is used.
George Williams BCS Huntsville Artificial Intelligence Center
Boeing Computer Services Internet: firstname.lastname@example.org
POBox 240002, M/S JY-58 UUCP: ...!uw-beaver!bcsaic!hsvaic!george
Huntsville AL 35824-6402 Phone: 205+464-4968 FAX: 205+464-4930