Comment 1 for bug 894241

Revision history for this message
Christophe Rhodes (csr21-cantab) wrote : Re: [Bug 894241] [NEW] mop for structures

sds <email address hidden> writes:

> Public bug reported:
>
> * (defstruct s a)
> S
> * (sb-pcl:class-direct-slots (find-class 's))
> (#<SB-PCL::STRUCTURE-DIRECT-SLOT-DEFINITION A>)
> * (sb-pcl:slot-definition-initargs (car *))
> NIL

I think both this and the answer from clisp are consistent with their
respective implementations of MAKE-INSTANCE: in SBCL, after the above,
  (make-instance 's :a 3)
signals an invalid initarg error, while in clisp the same form returns
#S(S :A 3). So I think what's needed is to take a step back and ask
whether either of these behaviours of MAKE-INSTANCE given just a
structure definition is more desireable. I think it's right not to
return S-A as a reader for the slot, because I would expect to be able
to define auxiliary methods on reader functions, but of course the
struct-generated one isn't a generic function.

Getting a real initarg in sbcl can be done with
  (defclass s ()
    ((a :initarg :a))
    (:metaclass structure-class))

Cheers,

Christophe