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

with-slots, the saga continues

In PCL 7/20/88:

1.  After installing the latest with-slots patches, i came accross the
following bug:

(defclass foo
     ((bar :initform nil)
      (baz :initform nil)))

(defmethod bazz ((foo foo))
  (with-slots (bar baz) foo
     (cons baz bar)))				; Expands OK.

(defmethod bazz ((foo foo))
  (with-slots (baz) foo
    baz))					; Expansion fails, BAZ declared
						; special.

(defmethod bazz2 ((foo foo))
  (with-slots (baz) foo
    baz						; This BAZ not expanded.
    baz))					; This BAZ is expanded.

In EXPAND-WITH-SLOTS, shouldn't the BODY of a WITH-SLOTS be walked like
it was a PROGN?  Here's a patch that seems to work:

(defun expand-with-slots (specs body env gensym instance translate-fn)
  `(let ((,gensym ,instance))
     ,@(and (symbolp instance)
	    `((declare (variable-rebinding ,gensym ,instance))))
     ,@(CDR (walk-form `(PROGN ,@BODY)		; KRA: Walk body as a PROGN.
		  #'(lambda (f c e)
		      (declare (ignore e))
		      (expand-with-slots-internal specs