Common Lisp includes a complex and powerful ``declaration''
mechanism that allows you to give the compiler special hints
about the types of data that will be stored in particular variables,
and about the ways those variables and functions will be used. This
package defines versions of all the Common Lisp declaration forms:
declare
, locally
, proclaim
, declaim
,
and the
.
Most of the Common Lisp declarations are not currently useful in
Emacs Lisp, as the byte-code system provides little opportunity
to benefit from type information, and special
declarations
are redundant in a fully dynamically-scoped Lisp. A few
declarations are meaningful when the optimizing Emacs 19 byte
compiler is being used, however. Under the earlier non-optimizing
compiler, these declarations will effectively be ignored.
proclaim
is a function, decl-spec
is evaluated and thus should normally be quoted.
proclaim
, except that it takes any number
of decl-spec arguments, and the arguments are unevaluated and
unquoted. The declaim
macro also puts an (eval-when (compile load eval) ...)
around the declarations so that they will
be registered at compile-time as well as at run-time. (This is vital,
since normally the declarations are meant to influence the way the
compiler treats the rest of the file that contains the declaim
form.)
progn
s''
throughout Lisp syntax, such as function bodies, let
bodies,
etc. Currently the only declaration understood by declare
is special
.
locally
is no different from progn
.
the
is ignored in this package;
in other words, (the type form)
is equivalent
to form. Future versions of the optimizing byte-compiler may
make use of this information.
For example, mapcar
can map over both lists and arrays. It is
hard for the compiler to expand mapcar
into an in-line loop
unless it knows whether the sequence will be a list or an array ahead
of time. With (mapcar 'car (the vector foo))
, a future
compiler would have enough information to expand the loop in-line.
For now, Emacs Lisp will treat the above code as exactly equivalent
to (mapcar 'car foo)
.
Each decl-spec in a proclaim
, declaim
, or
declare
should be a list beginning with a symbol that says
what kind of declaration it is. This package currently understands
special
, inline
, notinline
, optimize
,
and warn
declarations. (The warn
declaration is an
extension of standard Common Lisp.) Other Common Lisp declarations,
such as type
and ftype
, are silently ignored.
special
|
Since all variables in Emacs Lisp are ``special'' (in the Common
Lisp sense),
The declaration
In top-level contexts, it is generally better to write
|
inline
|
The
The following declarations are all equivalent. Note that the
Note: This declaration remains in effect after the containing source file is done. It is correct to use it to request that a function you have defined should be inlined, but it is impolite to use it to request inlining of an external function.
In Common Lisp, it is possible to use |
notinline
|
The |
optimize
|
This declaration controls how much optimization is performed by the compiler. Naturally, it is ignored by the earlier non-optimizing compilers.
The word
In this package, with the Emacs 19 optimizing compiler, the
Note that even compiling with
The |
warn
|
This declaration controls what sorts of warnings are generated
by the byte compiler. Again, only the optimizing compiler
generates warnings. The word |