> * (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 expected (:A) to be returned by the last form
I'm not sure why this is expected. The initargs relate to arguments to
make-instance, not to any structure constructor, and sbcl does not
define any initargs from defstruct forms. I'm particularly not
convinced that the inclusion of the structure accessor in
slot-definition-readers is sensible, given that I would expect that the
readers to name generic functions (and structure accessors from
defstruct in sbcl are not generic). In other words, sbcl's mop for
structures is consistent in this respect.
If you need a structure with generic accessors and initargs for
make-instance, the portable way to do that is with defclass and
:metaclass structure-class.
sds <email address hidden> writes:
> * (defstruct s a) class-direct- slots (find-class 's)) :STRUCTURE- DIRECT- SLOT-DEFINITION A>) slot-definition -initargs (car *))
> S
> * (sb-pcl:
> (#<SB-PCL:
> * (sb-pcl:
> NIL
>
> I expected (:A) to be returned by the last form
I'm not sure why this is expected. The initargs relate to arguments to -readers is sensible, given that I would expect that the
make-instance, not to any structure constructor, and sbcl does not
define any initargs from defstruct forms. I'm particularly not
convinced that the inclusion of the structure accessor in
slot-definition
readers to name generic functions (and structure accessors from
defstruct in sbcl are not generic). In other words, sbcl's mop for
structures is consistent in this respect.
If you need a structure with generic accessors and initargs for
make-instance, the portable way to do that is with defclass and
:metaclass structure-class.
Christophe