eval
eval form → {result}*
form—a form.
results—the values yielded by the evaluation of form.
Goes without saying. -kmp 8-Aug-91 7.9.2 4 Returns multiple values if \param{form} produces multiple values.
20.1.0 2Evaluates form in the current dynamic environment and the null lexical environment.
20.1.0 1eval is a user interface to the evaluator.
8.2.0 5The evaluator expands macro calls as if through the use of macroexpand-1.
9.1.0 3 It is an error to attempt to evaluate a declaration. Those \term{forms} that permit declarations to appear perform explicit checks for their presence.
Constants appearing in code processed by eval are not copied nor coalesced. The code resulting from the execution of eval references objects that are eql to the corresponding objects in the source code.
!!! Barmar: What about compiler macros?
(setq form '(1+ a) a 999) → 999 (eval form) → 1000 (eval 'form) → (1+ A) (let ((a '(this would break if eval used local value))) (eval form)) → 1000
None.
None.
\funref{evalhook},
\funref{applyhook}, macroexpand-1, Section 3.1.2 (The Evaluation Model)
20.1.0 4To obtain the current dynamic value of a symbol, use of symbol-value is equivalent (and usually preferable) to use of eval.
20.1.0 3Note that an eval form involves two levels of evaluation for its argument. First, form is evaluated by the normal argument evaluation mechanism as would occur with any call. The object that results from this normal argument evaluation becomes the value of the form parameter, and is then evaluated as part of the eval form. For example:
(eval (list 'cdr (car '((quote (a . b)) c)))) → bThe argument form
(list 'cdr (car '((quote (a . b)) c))) is evaluated in the usual way to produce the argument (cdr (quote (a . b))); this is then given to \funref{eval}
because \funref{eval} is being called explicitly,
andeval then evaluates its argument, (cdr (quote (a . b))), to produce b. Since a single evaluation already occurs for any argument form in any function form, eval is sometimes said to perform “an extra level of evaluation.”
Hooks are provided for user-supplied debugging routines to obtain control during the execution of an interpretive evaluator. \funref{evalhook} and \funref{applyhook} provide alternative interfaces to the evaluator mechanism for use by these debugging routines.