common-lisp Customization Optimization settings


Common Lisp has a way to influence the compilation strategies. It makes sense to define your preferred values.

Optimization values are between 0 (unimportant) and 3 (extremely important). 1 is the neutral value.

It's useful to always use safe code (safety = 3) with all runtime checks enabled.

Note that the interpretation of values is implementation specific. Most Common Lisp implementations make some use of these values.

SettingExplanationuseful default valueuseful delivery value
compilation-speedspeed of the compilation process20
debugease of debugging21 or 0
safetyrun-time error checking32
spaceboth code size and run-time space22
speedspeed of the object code23

An optimize declaration for use with declaim, declare and proclaim:

(optimize (compilation-speed 2)
          (debug 2)
          (safety 3)
          (space 2)
          (speed 2))

Note that you can also apply special optimization settings to portions of the code in a function using the macro LOCALLY.