3.3. Declarations [sec_3-3]

3.3.1. Declaration SPECIAL
3.3.2. Declaration EXT:CONSTANT-NOTINLINE
3.3.3. Function CONSTANTP
3.3.4. Declaration SAFETY
3.3.5. Declaration (COMPILE)
3.3.6. Declaration SPACE

The declarations (TYPE type variable ...), (FTYPE type function ...), are ignored by both the interpreter and the compiler.

3.3.1. Declaration SPECIAL

Declaration EXT:NOTSPECIALDeclarations (PROCLAIM '(SPECIAL variable)) and DEFCONSTANT are undone by the (PROCLAIM '(EXT:NOTSPECIAL variable)) declaration. This declaration can be used only in global PROCLAIM and DECLAIM forms, not in local DECLARE forms.

Warning

You cannot expect miracles: functions compiled before the EXT:NOTSPECIAL proclamation was issued will still be treating variable as special even after the EXT:NOTSPECIAL proclamation. See also Section 3.2.2.3, “Semantic Constraints ”.

Function EXT:SPECIAL-VARIABLE-PYou can use the function (EXT:SPECIAL-VARIABLE-P symbol &OPTIONAL environment) to check whether the symbol is a dynamic variable. environment of NIL or omitted means use the global environment. You can also obtain the current lexical environment using the macro EXT:THE-ENVIRONMENT (interpreted code only). This function will always return T for global special variables and constant variables.

3.3.2. Declaration EXT:CONSTANT-NOTINLINE

Constants defined by DEFCONSTANT but proclaimed EXT:CONSTANT-NOTINLINE will not be inlined by the compiler. This is useful for variables which remain constant within an a single Lisp process but may vary between processes and machines (such as endianness or word size) thus they should be written to #P".fas"s as symbols, not values.

3.3.3. Function CONSTANTP

Function CONSTANTP fully complies with [ANSI CL standard]. Additionally, some non-trivial forms are identified as constants, e.g., (CONSTANTP '(+ 1 2 3)) returns T.

Warning

Since DEFCONSTANT initial value forms are not evaluated at compile time, CONSTANTP will not report T of their name within the same compilation unit for the null lexical environment. This is consistent and matches questionable code using the pattern (IF (CONSTANTP form) (EVAL form)). Use EVAL-WHEN if you need recognition and the value during compile-time. See also Section 31.11.5, “Macro EXT:COMPILE-TIME-VALUE.

3.3.4. Declaration SAFETY

Declaration (OPTIMIZE (SAFETY 3)) results in safe compiled code: function calls are never eliminated. This guarantees the semantics described in [sec_3-5].

3.3.5. Declaration (COMPILE)

The declaration (COMPILE) has the effect that the current form is compiled prior to execution. Examples:

(LOCALLY (DECLARE (compile)) form)

executes the compiled version of form.

(LET ((x 0))
  (FLET ((inc () (DECLARE (compile)) (INCF x))
         (dec () (DECF x)))
    (VALUES #'inc #'dec)))

returns two functions. The first is compiled and increments x, the second is interpreted (slower) and decrements the same x.

This declaration can also be used to name the resulting compiled closure:

(LAMBDA (x) (DECLARE (compile ident)) x)
⇒ #<COMPILED-FUNCTION IDENT>
(FUNCTION-LAMBDA-EXPRESSION *)
⇒ NILsource is not preserved
⇒ T
⇒ IDENT
(FBOUNDP 'ident)
⇒ NILsic!

Note

The declaration (COMPILE) is ignored by the following special operators:

LABELS
FLET
MACROLET

3.3.6. Declaration SPACE

The declaration determines what metadata is recorded in the function object:

SPACE >= 2
documentation string is discarded
SPACE >= 3
the original lambda list is also discarded (most information is still available, see DESCRIBE, but the names of the positional arguments are not).

These notes document CLISP version 2.49+Last modified: 2012-05-04