help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Catching no generic method in EIEIO


From: Stefan Monnier
Subject: Re: Catching no generic method in EIEIO
Date: Sat, 28 May 2016 14:29:26 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

>>> The last form crashes -- I could, of course, implement this using
>>> defmethod on Two, but I want to this for any method.
>> (defmethod ((o t))
>> ...)
>> should do the trick.
> Didn't know you could do that, but it's not what I wanted. It implements
> the method for all objects. Where was what I wanted was to implement all
> methods on one object (or class).

FWIW, I think you can might be able to do that (at least for those
methods which don't have a default case like the one I provided above)
with something like

    (cl-defmethod cl-no-applicable-method (generic (x <myclass>) &rest args)
aka
    (defmethod no-applicable-method ((x <myclass>) generic &rest args)

but this will only catch those methods where the dispatch on <myclass>
was done on the first argument.

>> PS: Of course, I also recommend you switch to cl-generic
>> (i.e. use (cl-defmethod ...)).  It's more featureful and much faster.
> I'm going to fix all that when I port everything to emacs-25. I'm just
> waiting till that hits the shelf.

There's a forward compatibility cl-generic package in GNU ELPA, so you
should be able to start using it without dropping
backward compatibility.


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]