3.2 Making 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 the
type
declaration (see the chapter "Type Specifiers" in CLtL2):(declare (type-specifier variable-1 variable-2 ...))Adding
type
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.
Generated with Harlequin WebMaker