How can I unintern a qualified method?
Asked Answered
S

3

11

During development I defined an 'initialize-instance :after' method which after a while was not needed anymore and actually gets in my way because inside it calls code that is not valid anymore. Since the unintern function does not have an argument for the qualifier, is there any way I can "unintern" the symbol-qualifier combination of a method so that I don't have to slime-restart-inferior-lisp and load the project again from the start?

Stilly answered 12/5, 2011 at 10:12 Comment(0)
M
17

You can use the standard functions find-method and remove-method to do it:

(remove-method (find-method #'frob '(:before) '(vehicle t)))

I find it's much easier to use the slime inspector. If your function is named frob, you can use M-x slime-inspect #'frob RET to see a list of all methods on frob and select individual methods for removal.

Messiah answered 12/5, 2011 at 11:2 Comment(1)
If you're hoping to use slime-inspect for this sort of thing, ensure you have the "slime-fancy-inspector" in your slime-contribs. The generic slime inspector doesn't (at least at present...) make this sort of functionality readily accessible.Pirate
P
5

See the answer from Xach.

Methods are collected in generic functions. UNINTERN has nothing to do with that. What you want is to remove a method from a generic function.

Most Common Lisp IDEs have a way to do that. Either via the editor (M-x undefine...) or through some inspector tool.

Panamerican answered 12/5, 2011 at 11:29 Comment(0)
A
0

With AllegroCL 9.0. Xach's answer did not completely work for me.

The definition of my method:

defmethod my-method* ((expr forall-expr) bindings)

forall-expr is a class and bindings is un-typed. To find the method I had to use:

(find-method #'my-method* '() (mapcar #'find-class '(forall-expr t)))

Then to remove the definition of the method I used:

(remove-method #'my-method* (find-method #'my-method* '() (mapcar #'find-class '(forall-expr t))))

I was able to figure this out from footnote 7 at http://www.gigamonkeys.com/book/object-reorientation-classes.html and the examples from the Lisp HyperSpec for find-method http://clhs.lisp.se/Body/f_find_m.htm.

Anomie answered 10/4, 2013 at 22:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.