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

Re: >Getting rid of methods



        Reply to:   RE>>Getting rid of methods
>> Derek White asks:
>> Has someone written a function that "undoes" the effect of a definition?

This method when given either  a generic function, or a symbol which is the
name of a generic function, puts up a dialog with a list of all methods of
that generic function, and removes the method you choose from the list.

(defun undefine-method (generic-function)
  (setf generic-function (if (symbolp generic-function)
                           (fdefinition generic-function)
                           generic-function))
  (if (not (typep generic-function 'generic-function))
    (format t "~%~A is not a generic function." generic-function)
    (let ((method-to-be-removed
           (car (select-item-from-list 
                 (generic-function-methods generic-function)
                 :window-title "Select a method to be removed"))))
      (when (y-or-n-dialog 
             (format nil "OK to remove ~A?" method-to-be-removed))
        (remove-method generic-function method-to-be-removed)
        (format t "~%~A removed." method-to-be-removed)))))