Re: Calling specific method

"Pascal Bourguignon (as informatimago at gmail dot com)" <[email protected]> Mon, 20 Apr 2026 13:48:39 +0200
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
> On 17 Apr 2026, at 15:41, Erik Ronström (as erik dot ronstrom at doremir dot com) <[email protected]> wrote:
> 
> Hi,
> 
> (defclass a ()
>  )
> 
> (defclass b (a)
>  )
> 
> (defclass c (b)
>  )
> 
> (defmethod some-method ((obj a))
>  ; Do something
>  )
> 
> (defmethod some-method ((obj b))
>  ; Do something different
>  )
> 
> (defmethod some-method ((obj c))
>  (call-next-method))  ; <-- this will call some-method for class b
> 
> From some-method for class c, is it possible to explicitly call the method for class a rather than b?
> 


You’d have to search for the method yourself. Note how call-next-method is defined to be a local function, ie. it’s expanded by the defmethod macro. You could have a with-super-methods macro, that would search methods and let you call them.

But if the programmers of A, B, and C, programmed methods for SOME-METHOD specialised on A, B, and C, there must be a good reason. Why do you want to skip one or the other?


-- 
__Pascal Bourguignon__
[email protected]

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