From: ·····@bbn.com
Subject: CALL-NEXT-METHOD behavior
Date: 
Message-ID: <2oefhr$8tn@info-server.bbn.com>
I was diddling with call-next-method today, and discovered something
unexpected (annoying, but not totally outrageous).

I have three methods:

(defmethod one ((x foo) (y bar)) 
  (call-next-method))

(defmethod two (x (y bar)))

(defmethod three((x foo) y))


what I wanted was for (one <A> <B>) to call (two <A> <B>) but it called
(three <A> <B>).  'three' was in another [loaded] file, and I'd
forgotten about it.

question is: when there's >1 possible 'next-method', how do you know
which one gets called? how do you control it?

-- clint


(this actually stems from an error on my part, in that three should have
specialized on 'y', but it was yesterday's code and I was trying
something different today.)

From: Ken Anderson
Subject: Re: CALL-NEXT-METHOD behavior
Date: 
Message-ID: <KANDERSO.94Apr14114353@wheaton.bbn.com>
In article <··········@info-server.bbn.com> ·····@bbn.com writes:

   Path: info-server.bbn.com!news
   From: ·····@bbn.com
   Newsgroups: comp.lang.lisp,comp.lang.clos
   Date: 12 Apr 1994 15:42:51 GMT
   Organization: Bolt, Beranek and Newman Inc.
   Lines: 29
   Reply-To: ·····@bbn.com
   Xref: info-server.bbn.com comp.lang.lisp:12389 comp.lang.clos:2330

   I was diddling with call-next-method today, and discovered something
   unexpected (annoying, but not totally outrageous).

   I have three methods:

   (defmethod one ((x foo) (y bar)) 
     (call-next-method))

   (defmethod two (x (y bar)))

   (defmethod three((x foo) y))


   what I wanted was for (one <A> <B>) to call (two <A> <B>) but it called
   (three <A> <B>).  'three' was in another [loaded] file, and I'd
   forgotten about it.

   question is: when there's >1 possible 'next-method', how do you know
   which one gets called? how do you control it?

I think i understand your problem, though it is a bit underspecified as
stated. I assume one, two, and three are really the same generic function,
and the function is called with an instance of foo and and instance of bar,
and normal argument precedence order is used.  Then, the sorted list of
applicable methods is (ONE THREE TWO).  See p. 794 of CLtL'90.  

k
--
Ken Anderson 
Internet: ·········@bbn.com
BBN STC              Work Phone: 617-873-3160
10 Moulton St.       Home Phone: 617-643-0157
Mail Stop 6/4c              FAX: 617-873-3776
Cambridge MA 02138
USA
From: Lawrence G. Mayka
Subject: Re: CALL-NEXT-METHOD behavior
Date: 
Message-ID: <LGM.94Apr16163731@polaris.ih.att.com>
In article <··········@info-server.bbn.com> ·····@bbn.com writes:

   question is: when there's >1 possible 'next-method', how do you know
   which one gets called? how do you control it?

The next-method sequence is determined by the class precedence list
(inheritance ordering), method combination rules, argument precedence
order, etc.  You control it by altering these--e.g., changing the
order of superclasses, making some methods :AROUND instead of primary,
changing the :ARGUMENT-PRECEDENCE-ORDER of the generic function.

--
        Lawrence G. Mayka
        AT&T Bell Laboratories
        ···@ieain.att.com

Standard disclaimer.