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

Re: Redefining before and af

Subject:   RE>Redefining before and after

> Rob Browning writes:
> > Is there a way to redefine before and after methods for a class in CLOS
> > without quitting and restarting the program?  From what I can tell, if you
> > re-evaluate a definition of a before or after method it is added to the
> > list of before or after methods for the class.

> > I would be satisfied to be able to either clear all the existing before and
> > after methods of a given name from a class or to redefine them.

> As long as you redefine a before or after method on EXACTLY THE SAME
> CLASS as before, the new one will destroy the old one and replace it.
> The effects of before and after methods are only cumulative if you
> define a second before or after method on a class that is a super-
> or subclass of one that already has a before or after method.

> Thus one way to effectively kill a before, after or around method is to
> redefine it like this:
> (defmethod foo :before ((me tarzan)...)
> 	())
> where tarzan is the exact class name whose before method
> you want to kill. "Foo" of course also has to match the old method name.

> If you want to explicitly kill a before or after method, it's fairly
> easy to do it in the inspector. Just inspect the generic function's name,
> double-click on the "Function:" line in the inspector, then double-click
> on the method you want to kill, then choose "Kill Method" in the
> Commands popup menu. (This requires the use of Mark Nahabedian's
> clos-inspector-hacks code available in the contrib directory of
> cambridge.apple.com.)

Another way to do this which doesn't require Mark's clos-inspector-hacks: if the
method you wanted to remove was

(defmethod foo :before ((me tarzan) (you jane) a-monkey)

you could execute

(ccl::remove-method #'foo (list :before (list (find-class 'tarzan) (find-class
'jane) t)))

Rodney Daughtrey               Domain:  rodney@pro-solution.com
Proactive Solutions Inc.         UUCP:  uunet!proact!rodney   
5314 S. Yale Ave., Suite 402    Voice:  918.492.5199
Tulsa, OK  74135                  FAX:  918.492.5193