optimize
The optimize
declaration includes three concepts: debug
,
speed
, safety
and space
. Each of these declarations
can take one of the integer values 0, 1, 2 and 3. According to these
values, the implementation may decide how to compile or interpret a given
lisp form.
ECL currently does not use all these declarations, but some of them
definitely affect the speed and behavior of compiled functions. For
instance, the debug
declaration, as shown in
Table 2.1, the value of debugging is zero, the function
will not appear in the debugger and, if redefined, some functions might
not see the redefinition.
Behavior | 0 | 1 | 2 | 3 |
---|---|---|---|---|
Compiled functions in the same source file are called directly | Y | Y | N | N |
Compiled function appears in debugger backtrace | N | N | Y | Y |
All functions get a global entry (SI:C-LOCAL is ignored) | N | N | Y | Y |
A bit more critical is the value of safety
because as shown in
Table 2.2, it may affect the safety checks generated
by the compiler. In particular, in some circumstances the compiler may
assume that the arguments to a function are properly typed. For
instance, if you compile with a low value of safety
, and invoke
rplaca
with an object which is not a list, the consequences are
unspecified.
Behavior | 0 | 1 | 2 | 3 |
---|---|---|---|---|
The compiler generates type checks for the arguments of a lambda form, thus enforcing any type declaration written by the user. | N | Y | Y | Y |
The value of an expression or a variable declared by the user is assumed to be right. | Y | Y | N | N |
We believe type declarations and type inference and, if the type of a form is inferred to be right for a function, slot accessor, etc, this may be inlined. Affects functions like car , cdr , etc | Y | Y | N | N |
We believe types defined before compiling a file do not change before the compiled code is loaded. | Y | Y | N | N |
Arguments in a lisp form are assumed to have the appropriate types so that the form will not fail. | Y | N | N | N |
The slots or fields in a lisp object are accessed directly without type checks even if the type of the object could not be inferred (see line above). Affects functions like pathname-type , car , rest , etc. | Y | N | N | N |
declaim
and proclaim
Declarations established with proclaim
stay in force
indefinitely. Declarations established with declaim
in a file
do not persist after the file has been compiled. However, they are
established with proclaim
at load time when the compiled file
is loaded. This means that when compiling two files, declaim
declarations in the first file will not be in force when compiling the
second file unless the first file was loaded before the second one was
compiled.
cl_env_ptr
ecl_process_env ()
¶ECL stores information about each thread on a dedicated structure, which is the process environment. A pointer to this structure can be retrieved using the function or macro above. This pointer can be used for a variety of tasks, such as defining special variable bindings, controlling interrupts, retrieving function output values, etc.
Common Lisp and C equivalence
Lisp symbol | C function |
---|---|
compile | [Only in Common Lisp] |
eval | cl_object cl_eval (cl_object form) - DEPRECATED, see si_safe_eval |
macroexpand | cl_object cl_macroexpand(cl_narg narg, cl_object form, ...) |
macroexpand-1 | cl_object cl_macroexpand_1(cl_narg narg, cl_object form, ...) |
proclaim | [Only in Common Lisp] |
special-operator-p | cl_object cl_special_operator_p(cl_object form) |
constantp | cl_object cl_constantp (cl_narg narg, cl_object arg, ...) |