- ,@(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)))))))
- ;; FIXME: The way that we do things like (EVAL DEFCLASS-FORM)
- ;; here is un-ANSI-Common-Lisp-y and leads to problems
- ;; (like DEFUN for the type predicate being called more than
- ;; once when we do DEFCLASS at the interpreter prompt),
- ;; causing bogus style warnings. It would be better to
- ;; rewrite this so that the macroexpansion looks like e.g.
- ;; (PROGN
- ;; (EVAL-WHEN (:COMPILE-TOPLEVEL :LOAD-TOPLEVEL :EXECUTE)
- ;; (FROB1 ..))
- ;; (EVAL-WHEN (:LOAD-TOPLEVEL :EXECUTE)
- ;; (FROB2 ..)))
- (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 (eq *boot-state* 'complete)
- ;; FIXME: MNA (on sbcl-devel 2001-05-30) reported
- ;; (if I understand correctly -- WHN) that this call
- ;; is directly responsible for defining
- ;; class-predicates which always return
- ;; CONSTANTLY-NIL in the compile-time environment,
- ;; and is indirectly responsible for bogus warnings
- ;; about redefinitions when making definitions in
- ;; the interpreter. I didn't like his fix (deleting
- ;; the call) since I think the type system *should*
- ;; be informed about class definitions here. And I'm
- ;; not eager to look too deeply into this sort of
- ;; done-too-many-times-in-the-interpreter problem
- ;; right now, since it should be easier to make a
- ;; clean fix when EVAL-WHEN is made more ANSI (as
- ;; per the IR1 section in the BUGS file). But
- ;; at some point this should be cleaned up.
- (inform-type-system-about-std-class name))
- defclass-form)))))))
+ ;; 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"
+ ;; for code elsewhere in the same file which uses
+ ;; the name of the type.
+ ;;
+ ;; We only need to do this at compile time, because
+ ;; at load and execute time we write the actual
+ ;; full-blown class, so the "a class of this name is
+ ;; coming" note we write here would be irrelevant.
+ (eval-when (:compile-toplevel)
+ (preinform-compiler-about-class-type ',name))
+ ,defclass-form))))))))