Next: , Up: Handling of Types


3.2.1 Declarations as Assertions

The SBCL compiler treats type declarations differently from most other Lisp compilers. Under default compilation policy the compiler doesn't blindly believe type declarations, but considers them assertions about the program that should be checked: all type declarations that have not been proven to always hold are asserted at runtime.

Remaining bugs in the compiler's handling of types unfortunately provide some exceptions to this rule, see Implementation Limitations).

There are three type checking policies available in SBCL, selectable via optimize declarations.

Full Type Checks
All declarations are considered assertions to be checked at runtime, and all type checks are precise.

Used when (>= safety (max speed space compilation-speed). The default compilation policy provides full type checks.

Weak Type Checks
Any or all type declarations may be believed without runtime assertions, and assertions that are done may be imprecise.

Used when (< 0 safety (max speed space compilation-speed).

No Type Checks
All declarations are believed without assertions. Also disables argument count and array bounds checking.

Used when (= safety 0).