defstruct constructor uses slot-names in lambda list.
Norbert Paul <email address hidden> via lists.sourcefor
reading the hyperspec on defstruct I stumbled over what I consider a bug in
When I do
(macroexpand '(defstruct (boa (:constructor make-boa (b o a))) b o a))
in sbcl I get
(DEFUN MAKE-BOA (B O A)
'((:SLOT T . 1) (:SLOT T . 2) (:SLOT T . 3)) B O A))
(LOCALLY (DECLARE (NOTINLINE SB-KERNEL:
Note that it uses the slot symbols b, o, and a as parameters for
make-boa. Doesn't this violate the specification, as the hyperspec says
"The symbols which name the slots must not be used by the implementation
as the names for the lambda variables in the constructor function, since
one or more of those symbols might have been proclaimed special or might
be defined as the name of a constant variable."?
(defconstant c 'a-constant)
(defstruct (boo (:constructor make-boo (c))) c)
generates the error
; C names a defined constant, and cannot be used as a local variable.
A solution could be to replace each argument SYM by (make-symbol (symbol-mane SYM)).
I am using SBCL 1.0.52 on Debian Linux.