states that any class found by @code{find-class}, no matter what its
@code{class-name}, is redefined.
+@item
+@findex @sbmop{slot-definition-name}
+@tindex @cl{structure-class}
+@findex @cl{defstruct}
+an error is not signaled in the case of the @code{:name} initialization
+argument for @code{slot-definition} objects being a constant, when the
+slot definition is of type @code{structure-slot-definition} (i.e. it is
+associated with a class of type @code{structure-class}).
+
+This allows code which uses constant names for structure slots to
+continue working as specified in ANSI, while enforcing the constraint
+for all other types of slot.
+
@end itemize
@subsection Metaobject Protocol Extensions
@findex @cl{find}
@findex @cl{subseq}
-Users of this extension just make instances of @cl{sequence} subclasses
+Users of this extension just make instances of @code{sequence} subclasses
and transparently operate on them using sequence functions:
@lisp
(coerce (subseq (make-instance 'my-sequence) 5 10) 'list)
(error 'slotd-initialization-error :initarg :name :kind :missing))
(unless (symbolp name)
(error 'slotd-initialization-type-error :initarg :name :datum name :expected-type 'symbol))
- (when (constantp name)
+ (when (and (constantp name)
+ ;; KLUDGE: names of structure slots are weird, and their
+ ;; weird behaviour gets grandfathered in this way. (The
+ ;; negative constraint is hard to express in normal
+ ;; CLOS method terms).
+ (not (typep slotd 'structure-slot-definition)))
(error 'slotd-initialization-error :initarg :name :kind :constant :value name))
(when (and initformp (not initfunp))
(error 'slotd-initialization-error :initarg :initfunction :kind :missing))
(let ((sb-ext:*evaluator-mode* :compile))
(handler-bind ((warning #'error))
(eval `(let ()
- (defstruct destruct-no-warning-not-at-toplevel bar))))))
+ (defstruct defstruct-no-warning-not-at-toplevel bar))))))
(with-test (:name :bug-941102)
(let ((test `((defstruct bug-941102)
(multiple-value-bind (warn2 fail2) (ctu:file-compile test)
(assert (not warn2))
(assert (not fail2)))))
+
+(with-test (:name (defstruct :constant-slot-names))
+ (defstruct defstruct-constant-slot-names t)
+ (assert (= 3 (defstruct-constant-slot-names-t
+ (make-defstruct-constant-slot-names :t 3)))))