home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / lisp / mcl / 1057 < prev    next >
Encoding:
Text File  |  1992-07-22  |  1.6 KB  |  37 lines

  1. Path: sparky!uunet!darwin.sura.net!mips!apple!cambridge.apple.com!Laura_Bagnall@TERC.edu
  2. From: Laura_Bagnall@TERC.edu (Laura Bagnall)
  3. Newsgroups: comp.lang.lisp.mcl
  4. Subject: Re: >Getting rid of methods
  5. Message-ID: <00149.2794654153.26063@TERC.edu>
  6. Date: 22 Jul 92 16:55:25 GMT
  7. Sender: info-mcl-request@cambridge.apple.com
  8. Organization: TERC, 2067 Mass. Ave., Cambridge, MA, 02140
  9. Lines: 23
  10. Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
  11. Original-To: derek@cambridge.apple.com (derek)
  12. Original-Cc: info-mcl@cambridge.apple.com (info-mcl)
  13.  
  14.  
  15.         Reply to:   RE>>Getting rid of methods
  16. >> Derek White asks:
  17. >> Has someone written a function that "undoes" the effect of a definition?
  18.  
  19. This method when given either  a generic function, or a symbol which is the
  20. name of a generic function, puts up a dialog with a list of all methods of
  21. that generic function, and removes the method you choose from the list.
  22.  
  23. (defun undefine-method (generic-function)
  24.   (setf generic-function (if (symbolp generic-function)
  25.                            (fdefinition generic-function)
  26.                            generic-function))
  27.   (if (not (typep generic-function 'generic-function))
  28.     (format t "~%~A is not a generic function." generic-function)
  29.     (let ((method-to-be-removed
  30.            (car (select-item-from-list 
  31.                  (generic-function-methods generic-function)
  32.                  :window-title "Select a method to be removed"))))
  33.       (when (y-or-n-dialog 
  34.              (format nil "OK to remove ~A?" method-to-be-removed))
  35.         (remove-method generic-function method-to-be-removed)
  36.         (format t "~%~A removed." method-to-be-removed)))))
  37.