
3.7 CLOS optimizations
make-instance will usually be partially optimized at compile time, provided that the class argument is a compile-time constant (and is not of a metaclass known to be outside the scope ofstandard-class), and that the keyword parameter names (if any) are also compile-time constants. For example:(make-instance 'turtle :legs 4 :color (figure-it-out))is optimizable, whereas:
(make-instance 'turtle x 4 y (figure-it-out))is not. There is also a run-time component for assembling the optimization, which is generally invoked upon the first call for that kind of "make-instance." For finer-grained control over this run-time component, see the documentation for the following functions:
invalidate-all-mki-optimizations invalidate-generic-function invalidate-mki-optimization mki-optimization-enabled-p revalidate-all-mki-optimizations revalidate-mki-optimizationAny user-defined methods on
make-instance will defeat the previously -mentioned optimizations, and any user-defined primary or:around methods defined oninitialize-instance orshared-initialize will cause the optimization to run a bit slower.At all times, under any run-time changes to the class hierarchy or to the set of applicable initialization methods, the compiled code remains correct; at most, the run-time monitor will block the optimization when it is not appropriate.

Generated with Harlequin WebMaker