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


    Date: Fri, 19 Aug 88 16:56 EDT
    From: Jim Salem <Salem@Think.COM>

    It appears to be very difficult to write an UNDEFMETHOD in standard CLOS.  I
    suggest one be provided.

There is a version of undefmethod in PCL.  Unfortunately, the currently
distributed one is a little difficult to use.  This message has a
description, and a patch for a new one.

undefmethod is a macro, its argument list is:


If specializers is shorter than the number of required arguments of the
generic function it is padded with T's.  This means that

(defmethod foo ((x class) y z) ..)

can be undone by:  (undefmethod foo (class))

or by:  (undefmethod foo (class t t t))

(defmethod bar :before (x (y class) z) ..)

can be undone by:  (undefmethod bar :before (t class))

or by:  (undefmethod bar :before (t class t))

This version of undefmethod WAS NOT in the 8/24 version put on arisia
yesterday.  The version on arisia has now been patched to include the
following patches.

;from boot.lisp
(defun parse-method-or-spec (spec &optional (errorp t))
  (declare (values generic-function method method-name))
  (let (gf method name temp)
    (if (method-p spec)	
	(setq method spec
	      gf (method-generic-function method)
	      temp (and gf (generic-function-name gf))
	      name (if temp
			 (make-method-spec temp
					   (method-qualifiers method)
					     (method-type-specifiers method))))
		       (make-symbol (format nil "~S" method))))
	(multiple-value-bind (gf-spec quals specls)
	    (parse-defmethod spec)
	  (and (setq gf (and (or errorp (gboundp gf-spec))
			     (gdefinition gf-spec)))
	       (let ((nreq (compute-discriminating-function-arglist-info gf)))
		 (setq specls (append (parse-specializers specls)
				      (make-list (- nreq (length specls))
		   (setq method (get-method gf quals specls errorp))
		   (setq name
			 (intern-function-name (make-method-spec gf-spec
    (values gf method name)))

;from high.lisp

(defmacro undefmethod (&rest args)
  #+(or (not :lucid) :lcl3.0)
  (declare (arglist name {method-qualifier}* specializers))
  `(undefmethod-1 .,args))

(defun undefmethod-1 (args)
  (multiple-value-bind (gf method)
      (parse-method-or-spec args)
    (when (and gf method)
      (remove-method gf method)

;from high.lisp, delete the definition of undefmethod-setf