Chapter 2. Evaluation and compilation

2.1. Declarations
2.2. C Reference
ecl_process_env — Per-thread environment
ANSI Dictionary — Common Lisp and C equivalence

2.1. Declarations


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 compie 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, if the value of debugging is zero, the function will not appear in the debugger and, if redefined, some functions might not see the redefinition.

Table 2.1. Behavior for different levels of DEBUG

Compiled functions in the same source file are called directlyYYNN
Compiled function appears in debugger backtraceNNYY
All functions get a global entry, that is, SI:C-LOCAL is ignored.NNYY

A bit more critical is the value of SAFETY because as shown in Table 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, the consequences are unspecified.

Table 2.2. Behavior for different levels of SAFETY

The compiler generates type checks for the arguments of a lambda form, thus enforcing any type declaration written by the user.NYYY
The value of an expression or a variable declared by the user is assumed to be right.YYNN
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, etcYYNN
We believe types defined before compiling a file not change before the compiled code is loaded.YYNN
Arguments in a lisp form are assumed to have the appropriate types so that the form will not fail.YNNN
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.YNNN