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

Re: Specializing methods on t with qualifiers

    Date: Wed, 31 Aug 88 13:42:46 EDT
    From: rich%linus@mitre-bedford.ARPA

    In the AAAI PCL release (using Symbolics 7.2):


    (defmethod blah (xxx) (princ " Primary "))

    (defmethod blah :before (xxx) (princ " Before "))

    (defmethod blah :after (xxx) (princ " After "))

    When you call blah, you get an error.  

The following patch should solve this problem for you.

;from dcode.lisp
(defun compute-discriminator-code-1 (generic-function)
  (let ((combined (generic-function-combined-methods generic-function))
	(methods (generic-function-methods generic-function))
	(std-class (find-class 'standard-class))
	(t-class *the-class-t*)
	(r/w nil))
    (cond ((null combined)
	   (make-no-methods-dcode generic-function))
	  ((and (null (cdr combined))
		(every #'(lambda (x) (eq x t-class)) (caar combined)))
           (make-default-method-only-dcode generic-function))
	  ((dolist (e combined)
	     (when (dolist (specl (car e))
		     (when (listp specl) (return 't)))
	       (return 't)))
	   (make-individual-method-dcode generic-function))
	     (dolist (m methods)
	       (let* ((specls (method-type-specifiers m))
		      (spec0 (car specls))
		      (spec1 (cadr specls)))
		 (cond ((and (memq r/w '(nil r))
			     (standard-reader-method-p m)
			     (not (listp spec0))
			     (if (symbolp spec0)
				 (and (neq spec0 'standard-generic-function)
				      (neq spec0 'generic-function))
				 (eq (class-of spec0) std-class)))
			(setq r/w 'r))
		       ((and (memq r/w '(nil w))
			     (standard-writer-method-p m)
			     (not (listp spec1))
			     (if (symbolp spec1)
				 (and (neq spec1 'standard-generic-function)
				      (neq spec1 'generic-function))
				 (eq (class-of spec1) std-class)))
			(setq r/w 'w))
			(return t))))))
	   (if (eq r/w 'r)
	       (make-all-std-class-readers-dcode generic-function) 
	       (make-all-std-class-writers-dcode generic-function)))
           (make-multi-method-dcode generic-function)))))

;from dcode.lisp
(defmethod make-default-method-only-dcode (generic-function)
  (cdar (generic-function-combined-methods generic-function)))

    Also, it seems as if you can't evaluate the forms above in the lisp
    listener (methods specialized to other classes seem to work fine).

I can't seem to duplicate this problem on my 3600 here.  Can you give me
some more details about it?