Re: Finding the applicable methods...

"Tim Bradshaw (as tfb at tfeb dot org)" <[email protected]> Tue, 14 Jul 2026 15:57:30 +0100
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
On 14 Jul 2026, at 08:34, Tim Bradshaw (as tfb at cley dot com) <[email protected]> wrote:
> 
> The interesting case would be if there were multiple around methods or multiple primary methods of varying specificities.
> 
> Then both around and primary methods should rank most-specific first, but all the around methods will still rank above all the primary methods.

I was slightly wrong (or at least confusing) about this.

Given

(defclass a ()
  ())

(defclass b (a)
  ())

(defmethod foo ((a a))
  'a)

(defmethod foo ((b b))
  'b)

(defmethod foo :around ((a a))
  (call-next-method))

(defmethod foo :around ((b b))
  (call-next-method))

Then

? (compute-applicable-methods #'foo (list (make-instance 'b)))
(#<standard-method foo (:around) (b) 81807754E3>
 #<standard-method foo nil (b) 8180775513>
 #<standard-method foo (:around) (a) 81807754CB>
 #<standard-method foo nil (a) 81807754FB>)

And these are, indeed, sorted in precedence order, which means the A methods are below the B methods.  But the order of calling will for a B be

around method for B
  calls around method for A
    calls main method for B
      (which, if it used call-next-method, could call the main method for A
    ...
  ...
...

The order of calling for an A will be

around method for A
  calls main method for A
...

--tim



_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html