![[LISPWORKS]](/image.pl?url=http%3a%2f%2fwww.lispworks.com%2fdocumentation%2fHyperSpec%2fBody%2f..%2fGraphics%2fLWSmall.gif&f=jpg&w=240)
![[Common Lisp HyperSpec (TM)]](/image.pl?url=http%3a%2f%2fwww.lispworks.com%2fdocumentation%2fHyperSpec%2fBody%2f..%2fGraphics%2fCLHS_Sm.gif&f=jpg&w=240)
Syntax:
(optimize{quality| (qualityvalue)}*)
Arguments:
quality---anoptimize quality.
value---one of theintegers0,1,2, or3.
Valid Context:
Binding Types Affected: None.
Description:
Advises the compiler that eachquality should be given attention according to the specified correspondingvalue. Eachquality must be asymbol naming anoptimize quality; the names and meanings of the standardoptimize qualities are shown in the next figure.
Name Meaningcompilation-speed speed of the compilation processdebug ease of debuggingsafety run-time error checkingspace both code size and run-time spacespeed speed of the object code
Figure 3-25. Optimize qualities
There may be other,implementation-definedoptimize qualities.
Avalue0 means that the correspondingquality is totally unimportant, and3 that thequality is extremely important;1 and2 are intermediate values, with1 the neutral value.(quality 3) can be abbreviated toquality.
Note thatcode which has the optimization(safety 3), or justsafety, is calledsafecode.
The consequences are unspecified if aquality appears more than once withdifferentvalues.
Examples:
(defun often-used-subroutine (x y) (declare (optimize (safety 2))) (error-check x y) (hairy-setup x) (do ((i 0 (+ i 1)) (z x (cdr z))) ((null z)) ;; This inner loop really needs to burn. (declare (optimize speed)) (declare (fixnum i)) ))
See Also:
declare,declaim,proclaim,Section 3.3.4 (Declaration Scope)
Notes:
Anoptimize declaration never applies to either avariable or afunctionbinding. Anoptimize declaration can only be afree declaration. For more information, seeSection 3.3.4 (Declaration Scope).