Next Previous Up Top Contents Index

7 The Compiler

7.5 Declare, proclaim, and declaim

declare

Special form

declare (declaration *)

There are two distinct uses ofdeclare, one is to declare Lisp variables as "special" (this affects the semantics of the appropriate bindings of the variables), and the other is to provide advice to help the Common Lisp system (in reality the compiler) run your Lisp code faster, or with more sophisticated debugging options.
The special formdeclare behaves computationally as if it is not present (other than to affect the semantics), and is only allowed in certain contexts, such as after the variable list in alet,do,defun, etc.
(Consult the syntax definition of each special form to see if it takes declare forms and/or documentation strings.)
See the LispWorks Reference Manual for more detailed information ondeclare, including some LispWorks extensions to Common Lisp.
proclaim

Function

proclaim declaration-list

declaration-list must be a list of declaration forms to be put into immediate and pervasive effect.
Unlikedeclare,proclaim is a function that parses the declarations in the list (usually a quoted list, note), and puts their semantics and advice into global effect. This can be useful when compiling a file for speedy execution, since a proclamation such as:
(proclaim '(optimize (speed 3) (space 0) (debug 0)))

means that the rest of the file is compiled with these optimization levels in effect. (The other way of doing this is to make appropriate declarations in every function in the file).
proclaim simply returnsnil.
declaim

Macro

This is a macro equivalent toproclaim.

Below are some examples:

(proclaim '(special *fred*))
(proclaim '(type single-float x y z))
(proclaim '(optimize (safety 0) (speed 3)))

Asproclaim involves parsing a list of lists of symbols and is intended to be used a few times per file, its implementation is not optimized for speed - it makes little sense to use it other than at top level.

Do not forget to quote the argument list if it is a constant list.(proclaim (special x)) attempts to call functionspecial.

7.5.1 - Naming conventions

LispWorks User Guide - 14 Oct 1998

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker