Re: Calling specific method

Martin Simmons <[email protected]> Fri, 17 Apr 2026 17:12:19 +0100
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
I would just put the "Do something" code from the method for class a into a
separate function and call that from the methods for classes a and c.

-- 
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/



>>>>> On Fri, 17 Apr 2026 17:25:25 +0200, Erik Ronström (as erik dot ronstrom at doremir dot com) said:
> 
> Thanks, I managed to get the method object... but how do I call it?
> 
> (defmethod some-method ((obj c))
>    (let ((method (find-method (find-method #'some-method nil (find-class 'a)))))
> 
>      ;; method was found, but how to call it?
>      (call-method method) ; call-method is not defined in this context
>      (funcall method obj) ; method is not a function
> )
> 
> 
> 
> 
> Den 2026-04-17 kl. 16:23, skrev Toomas Altosaar:
> 
> Use find-Metrodome
> 
> > On 17. Apr 2026, at 16.42, 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?
> >
> > Erik
> 
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> [email protected]
> http://www.lispworks.com/support/lisp-hug.html
> 

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