VariablePackage: compilerToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
This page is new in 8.2. Minimal update since 8.2 release.

verify-type-declarations-switch

As with all compiler switch variables, the value of this variable can be t, nil, or a function object that accepts five arguments and returns t or nil. The arguments passed to the function will be the values of the safety, space, speed, debug, and compilation-speed optimization qualities, in that order. nil is equivalent to a function that always returns nil and t to a function that always returns t. When the value is a function and we say t (or true) or nil (or false) in the text below, we mean that the function returns, respectively, t or nil.

Code compiled with this switch true will have additional runtime type checking done of any lambda or let bindings of a declared variable and any setqs to that variable to ensure that the value is of the correct type. If the variable is bound to an inappropriate value, a continuable type-error is generated.

The declared types are checked in the following three places:

  1. The binding of a lexical variable in a lambda form
  2. The binding of a lexical variable in a let form
  3. The setq'ing of a lexical variable

Further:

Example

As we note below, in the default this switch is true when safety is greater than 1. Speed 3/Safety 2, used in this example, makes this switch and the various trust-* switches true in the default.

cl-user(1): (compile
              (defun foo (x y)
                (declare (optimize (speed 3) (safety 2)) (integer x))
                (setq x y)
                (let ((z x))
                  (declare (fixnum z))
                  z)))
foo
nil
nil
cl-user(2): (foo 10 20)
20
cl-user(3): (foo 10 (1+ most-positive-fixnum))
Error: about to bind z to 536870912, which is not of type
       (integer -536870912 536870911).
  [condition type: type-error]

Restart actions (select using :continue):
 0: store the value anyway.
 1: Return to Top Level (an "abort" restart).
 2: Abort entirely from this (lisp) process.
[1] cl-user(4): :cont
536870912
cl-user(5): (foo 10 20.0)
Error: about to setq x to 20.0, which is not of type (integer * *).
  [condition type: type-error]

Restart actions (select using :continue):
 0: store the value anyway.
 1: Return to Top Level (an "abort" restart).
 2: Abort entirely from this (lisp) process.
[1] cl-user(6): :res
cl-user(7): (foo 10.0 20)
Error: about to bind function argument x to 10.0, which is not of type
       (integer * *).
  [condition type: type-error]

Restart actions (select using :continue):
 0: store the value anyway.
 1: Return to Top Level (an "abort" restart).
 2: Abort entirely from this (lisp) process.
[1] cl-user(8): 

Initially true if safety is greater than 1. This means that (optimize (speed 3) (safety 2)) is (with default values) the only safety/speed combination that turns on both this switch and trust-declarations-switch and trust-dynamic-extent-declarations-switch.

See compiling.htm for information on the compiler.


Copyright (c) 1998-2012, Franz Inc. Oakland, CA., USA. All rights reserved.
Documentation for Allegro CL version 8.2. This page is new in the 8.2 release.
Created 2010.1.21.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
This page is new in 8.2. Minimal update since 8.2 release.