[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: typep optimization for CLOS-classes

Matthias Lindner <matthias@intellektik.informatik.th-darmstadt.de> writes:

> Reading the result of the second compilation triggers an error!
> I think this problem occurs, as the compiler optimized the expression 
> (typep a '<B>) to (clos::subclassp (clos:class-of a) (find-class '<B>)).
> This is correct - unfortunately the compilation of this expression
> causes the insertion of #.(FIND-CLASS '<B>) into the .fas-file
> *before* the definition of class <B>.

Yes, this is unfortunate in your case, but it enables faster type checking.
The compiler's optimization of (typep a '<B>) into
(clos::subclassp (clos:class-of a) (load-time-value (find-class '<B>)))
is allowed by paragraph of the CLHS:

   "All conforming programs must obey the following constraints...:
    Classes defined by `defclass' in the compilation environment must
    be defined at run time to have the same superclasses and same

> It's not a big problem as it can be fixed by moving the definition of
> class <B> before the definition of method ISA-B, but sometimes it is
> annoying to sort class definition like this.

Yes, that's what you have to do: make sure that all class definitions
that were present in the compilation environment are loaded into the
runtime environment before all other runtime code.