2.2 Evaluation and compilation

2.2.1 Compiler declaration 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.

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

Table 2.1: Behavior for different levels of debug

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.

Behavior0123
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 do 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

Table 2.2: Behavior for different levels of safety

2.2.2 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.

2.2.3 C Reference

C/C++ identifier: 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.

2.2.3.1 ANSI Dictionary

Common Lisp and C equivalence

Lisp symbolC function
compile[Only in Common Lisp]
evalcl_object cl_eval (cl_object form) - DEPRECATED, see si_safe_eval
macroexpandcl_object cl_macroexpand(cl_narg narg, cl_object form, ...)
macroexpand-1cl_object cl_macroexpand_1(cl_narg narg, cl_object form, ...)
proclaim[Only in Common Lisp]
special-operator-pcl_object cl_special_operator_p(cl_object form)
constantpcl_object cl_constantp (cl_narg narg, cl_object arg, ...)