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

bug with defmethod documentation strings

There is a bug in the current version of PCL which affects defmethod's
whose body is just a single string.  The bug is apparent in the
following example:

(defmethod type-string ((x symbol)) "a symbol")

(type-string 'foo) ==> NIL instead of "a symbol"

The following patch fixes this bug.  Anyone who has run into this
problem should install this patch in their macros.lisp file.

; from macros.lisp
(eval-when (compile load eval)
(defun extract-declarations (body &optional environment)
  (declare (ignore environment)
	   (values documentation declarations body))
  (let (documentation declarations form)
    (when (and (stringp (car body))
	       (cdr body))
      (setq documentation (pop body)))
      (when (null body) (return))
      (setq form (car body))
      (cond ((and (listp form) (eq (car form) 'declare))
	     (dolist (declaration (cdr (pop body)))
	       (push declaration declarations)))
	    (t (return))))
    (values documentation `((declare ,.declarations)) body)))