It is often useful to be able to give the compiler extra knowledge about the program forms that it is compiling. The language includes special declaration forms that have no effect when interpreted, but are meaningful to the compiler as it traverses the program.
Offer the information contained in the clause… forms to the compiler, which it may or may not use when compiling the program.
Each clause is a list, the first element of each clause is a symbol defining the type of declaration, the interpretation of any other elements in the clause depends upon the declaration type.
The following table lists the syntax of all currently supported declaration types:
This declaration tells the compiler that all symbols variables have lexical bindings for the extent of the current lexical scope. This is often useful to prevent spurious compiler warnings.
This tells the compiler that all symbols variables have special (dynamic) bindings for the extent of the current lexical scope.
(It is important that the compiler is able to distinguish special bindings from lexical bindings, since different instruction sequences must be generated to access the different types of binding.)
Directs the compiler not to warn about bindings for variables… being unreferenced.
Tells the compiler that it should consider inlining calls to the functions called names…. Inlining will only occur if these functions are declared in the same module as, and after, the declaration itself.
This declaration should occur at the top-level of a program; it tells the compiler that the forms in the program will be evaluated within the context of the module called module-name (a symbol).
Explicitly specifies the particular language dialect that the current module or file body is written for. Language dialects included with the librep distribution include Rep, Scheme and Unscheme. These are also the names of the modules that should be imported to use a particular dialect.
By default, the Rep is assumed for code outside module
definitions. For code inside a module definition the list of imported
modules is scanned for a known language dialect (i.e. if the module
rep, then the Rep language dialect is compiled for).
Tell the compiler that it may register-allocate variables, even if it
can’t prove that doing so wouldn’t produce incorrect results if
call/cc causes a function call to return more than once
(see Continuations). This declaration applies to the entire file
that it occurs in.
Without this declaration, the compiler will only register-allocate bindings if the following conditions are met:
this declaration is often useful where
call/cc isn’t used, and
there is a lot of side effecting of local variables.
Declaration forms always evaluate to false.
A second type of declaration is the
eval-when-compile form, it
allows Lisp forms to be evaluated only at compile-time.
This form tells the system that form should only be evaluated when the containing code is being compiled.
The compiler knows to recognize forms of the pattern
(eval-when-compile (require 'feature)) as marking that
feature should be imported at compile-time. Any other forms
are simply evaluated in an unspecified environment.
eval-when-compile forms alway evaluate to
false, when compiled they evaluate to the result of evaluating
the form at compile-time.