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

Re: add-method when method exists

  Date: Wed, 23 Dec 87 13:04 PST
  From: Gregor.pa@XEROX.COM
  Subject: add-method when method exists
  To: common-lisp-object-system@SAIL.STANFORD.EDU
  Message-ID: <871223130432.9.GREGOR@SPIFF.parc.xerox.com>
  In the current version of the spec, if add-method is used to add a
  method to a generic function and there is already a method with the same
  specializers and qualifiers and error is signaled.  I think thats a bad
  idea, I think it should just remove the old method and add the new one.
  Note that it should NOT call remove-method to remove the old one.

  The reason is that very often you want to replace an existing method
  with a new method.  Take the following example:
  (defmethod foo :before ((x object)) 'before)
  (defmethod foo ((x object)) 'primary)
  If I want to redefine the second method, I want to replace it with the
  new method, I don't want to first remove the old method because if I do,
  the generic function will be in an illegal state (it will have no
  primary method).
I agree that an error should not be signaled, but i don't see anything
wrong with calling REMOVE-METHOD.  I see nothing illegl about a
generic function without a primary method, and regularly define
protocols that have no primary methods just :AFTER methods.