Skip to main content

declaim

declaim Macro

Syntax:

declaim {declaration-specifier}* ! implementation-dependent

Evaluation and

Arguments and Values:

declaration-specifier—a declaration specifier ; not evaluated.

Description:

Establishes the declarations specified by the declaration-specifiers.

If a use of this macro appears as a top level form in a file being processed by the file compiler , the proclamations are also made at compile-time. As with other defining macros, it is unspecified whether or not the compile-time side-e↵ects of a declaim persist after the file has been compiled.

Examples:

See Also:

declare, proclaim

Expanded Reference: declaim

Declaring Special Variables

declaim establishes global declarations at both compile time and load time when it appears as a top level form.

(declaim (special *verbose*))

(setq *verbose* t)
=> T

Declaring Optimization Settings

(declaim (optimize (speed 3) (safety 0) (debug 0)))
;; Globally sets optimization preferences for subsequent compilations.

Multiple Declarations in One Form

declaim accepts multiple declaration specifiers.

(declaim (special *x* *y*)
(type integer *x*)
(optimize (speed 2)))

declaim vs. proclaim

declaim is a macro and is recognized at compile time. proclaim is a function and only takes effect at run time. Prefer declaim for top-level proclamations.

;; declaim works at compile time:
(declaim (inline my-fast-fn))

;; proclaim would need eval-when for the same effect:
(eval-when (:compile-toplevel :load-toplevel :execute)
(proclaim '(inline my-fast-fn)))

Declaring Function Inlining

(declaim (inline square))

(defun square (x) (* x x))
=> SQUARE
;; The compiler is advised to inline calls to square.