3.2 Making declarations

3.2.2 TYPE declarations

Type declarations specify the data types of the values of Lisp expressions. Lisp normally checks the types of all arguments to a predefined function at run-time. Atype declaration allows the Compiler to eliminate type checking. The Compiler extensively usestype declarations to produce faster and more efficient code; the interpreter ignorestype declarations.

Atype declaration has the following form:

(declare (type type-specifier variable-1 variable-2 ...))
If the type specifier is one of the Common Lisp atomic types, you can use a shorter form of thetype declaration (see the chapter "Type Specifiers" in CLtL2):

(declare (type-specifier variable-1 variable-2 ...))
Addingtype declarations to code with arithmetic operations can make the operations faster by significantly reducing the type-checking and type-dispatching overhead of function calls. To obtain the most efficient arithmetic operations, you must often specify the value types of an expression as well as the argument types of the expression. See Section 3.3 on page 49 for a discussion of the most effective way to usetype declarations.


The Advanced User's Guide - 9 SEP 1996

Generated with Harlequin WebMaker