- options))
- (defstruct-p (and (eq *boot-state* 'complete)
- (let ((mclass (find-class metaclass nil)))
- (and mclass
- (*subtypep mclass
- *the-class-structure-class*))))))
- (do-standard-defsetfs-for-defclass *accessors*)
- (let ((defclass-form
- (make-top-level-form `(defclass ,name)
- (if defstruct-p '(:load-toplevel :execute) *defclass-times*)
- `(progn
- ,@(mapcar #'(lambda (x)
- `(declaim (ftype (function (t) t) ,x)))
- *readers*)
- ,@(mapcar #'(lambda (x)
- #-setf (when (consp x)
- (setq x (get-setf-function-name (cadr x))))
- `(declaim (ftype (function (t t) t) ,x)))
- *writers*)
- (let ,(mapcar #'cdr *initfunctions*)
- (load-defclass ',name
- ',metaclass
- ',supers
- (list ,@canonical-slots)
- (list ,@(apply #'append
- (when defstruct-p
- '(:from-defclass-p t))
- other-initargs))
- ',*accessors*))))))
- (if defstruct-p
- (progn
- (eval defclass-form) ; Define the class now, so that..
- `(progn ; ..the defstruct can be compiled.
- ,(class-defstruct-form (find-class name))
- ,defclass-form))
- (progn
- (when (and (eq *boot-state* 'complete)
- (not (member 'compile *defclass-times*)))
- (inform-type-system-about-std-class name))
- defclass-form)))))))
+ options))
+ ;; DEFSTRUCT-P should be true, if the class is defined with a
+ ;; metaclass STRUCTURE-CLASS, such that a DEFSTRUCT is compiled
+ ;; for the class.
+ (defstruct-p (and (eq *boot-state* 'complete)
+ (let ((mclass (find-class metaclass nil)))
+ (and mclass
+ (*subtypep
+ mclass
+ *the-class-structure-class*))))))
+ (let ((defclass-form
+ `(progn
+ ,@(mapcar (lambda (x)
+ `(declaim (ftype (function (t) t) ,x)))
+ *readers*)
+ ,@(mapcar (lambda (x)
+ `(declaim (ftype (function (t t) t) ,x)))
+ *writers*)
+ (let ,(mapcar #'cdr *initfunctions*)
+ (load-defclass ',name
+ ',metaclass
+ ',supers
+ (list ,@canonical-slots)
+ (list ,@(apply #'append
+ (when defstruct-p
+ '(:from-defclass-p t))
+ other-initargs)))))))
+ (if defstruct-p
+ (let* ((include (or (and supers
+ (fix-super (car supers)))
+ (and (not (eq name 'structure-object))
+ *the-class-structure-object*)))
+ (defstruct-form (make-structure-class-defstruct-form
+ name slots include)))
+ `(progn
+ (eval-when (:compile-toplevel :load-toplevel :execute)
+ ,defstruct-form) ; really compile the defstruct-form
+ (eval-when (:compile-toplevel :load-toplevel :execute)
+ ,defclass-form)))
+ `(progn
+ ;; By telling the type system at compile time about
+ ;; the existence of a class named NAME, we can avoid
+ ;; various bogus warnings about "type isn't defined yet".
+ ,(when (and
+ ;; But it's not so important to get rid of
+ ;; "not defined yet" warnings during
+ ;; bootstrapping, and machinery like
+ ;; INFORM-TYPE-SYSTEM-ABOUT-STD-CLASS
+ ;; mightn't be defined yet. So punt then.
+ (eq *boot-state* 'complete)
+ ;; And although we know enough about
+ ;; STANDARD-CLASS, and ANSI imposes enough
+ ;; restrictions on the user overloading its
+ ;; methods, that (1) we can shortcut the
+ ;; method dispatch and do an ordinary
+ ;; function call, and (2) be sure we're getting
+ ;; it right even when we do it at compile
+ ;; time; we don't in general know how to do
+ ;; that for other classes. So punt then too.
+ (eq metaclass 'standard-class))
+ `(eval-when (:compile-toplevel)
+ ;; we only need :COMPILE-TOPLEVEL here, because this
+ ;; should happen in the compile-time environment
+ ;; only.
+ ;; Later, INFORM-TYPE-SYSTEM-ABOUT-STD-CLASS is
+ ;; called by way of LOAD-DEFCLASS (calling
+ ;; ENSURE-CLASS-USING-CLASS) to establish the 'real'
+ ;; type predicate.
+ (inform-type-system-about-std-class ',name)))
+ ,defclass-form))))))))