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

Re: :accessor-prefix bug

> I have uncovered what seems to me to be a bug with :accessor-prefix.  For
> example:

> (defclass foo ()
>   ((this :initform 'a))
>   (:accessor-prefix nil))

> (defmethod-setf this ((f foo)) (x)
>   (print 'here)
>   (setf (slot-value f 'this) x))

> (defclass bar (foo)
>   ((this :initform 'b)		; simply define a new initial value
>    (that :initform 'c))
>   (:accessor-prefix nil))

> In class FOO I use :accessor-prefix to generate the THIS and SETF-THIS
> methods.  The SETF-THIS method is then specialized.  In class BAR
> :accessor-prefix is supposed to define THA> T and SETF-THAT methods, and
> allow the THIS and specialized SETF-THIS methods to be inherited.  It
> however seems to redefine the SETF-THIS method:

> (setq f (make-instance 'foo))
> #<FOO 21323>
> (this f)
> A
> (setf (this f) 'k)
> HERE			; specialized method was run
> K
> (this f)
> K

> (setq b (make-instance 'bar))
> #<BAR 23243>
> (this b)
> B
> (that b)
> C
> (setf (this b) 'k)
> K			; the HERE message is not printed!!!
> (this b)
> K

> A temporary solution is to not use accessor prefix:

> (defclass bar (foo)
>   ((this :initform 'b)
>    (that :initform 'c :accessor that)))

> It would be nice to see :accessor-prefix work correctly though.

In reviewing this report, the problem is rather that a SETF method
is being generated for the THIS slot of the subclass. This is actually
contrary to the 87-002 spec, in which is stated that reader and writer
methods are only generated when requested. However, since this is a PCL
bug, I would suggest you send the bug to the CommonLoops mailing list.