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

PCL bug or CLOS spec issue?



When I try to define a recursive method for (setf foo), and it is the
FIRST method being defined for (setf foo), I get an error message from
PCL's code walker, because the use of (setf foo) in the body is not (yet)
acceptable.

It seems to me that a self contained recursive method (even for (setf foo))
should not require any kind of "forward declaration' -- 
  e.g., (ENSURE-GENERIC-FUNCTION '(setf foo) :lambda-list ...) --
that the lambda-list of the method should establish the lambda-list for
the generic function (SETF FOO), and thus the generic function should 
be callable from within the method.

In other words, I think the code below should be portable.
Opinions?

neil
----------------------------------------------------------------
(defclass xxx () ((slot1) (slot2) (delegate :reader delegate)))

(defmethod foo ((x xxx))
  (let ((d (delegate x)))
    (if d
	(foo d)
	(+ (slot-value x 'slot1) (slot-value x 'slot2)))))

(defmethod (setf foo) (new (x xxx))
  (let ((d (delegate x)))
    (if d
	(setf (foo d) new)
	(setf (slot-value x 'slot1) new
	      (slot-value x 'slot2) 0))))