EVAL(3cl)

Common Lisp Reference

EVAL(3cl)

 

NAME

eval – evaluate a form in the  in the current dynamic environment and the null lexical environment (function)

SYNOPSIS


eval form { result }*
 

ARGUMENTS and VALUES

form — a form

results—the values yielded by the evaluation of form.

DESCRIPTION

Evaluates form in the current dynamic environment and the null lexical environment.

eval is a user interface to the evaluator.

The evaluator expands macro calls as if through the use of macroexpand-1.

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.

AFFECTED BY

(none)

EXCEPTIONAL SITUATIONS

(none)

NOTES

To obtain the current dynamic value of a symbol , use of symbol-value is equivalent (and usually preferable) to use of eval.

Note 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 )))) b

The argument form (list cdr (car ’((quote (a . b)) c))) is evaluated in the usual way to produce the argument (cdr (quote (a . b))); eval 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.”

EXAMPLES

( 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

SEE ALSO

macroexpand-1(3cl)

AUTHOR and COPYRIGHT

Substantial portions of this page are taken from draft proposed American National Standard for Information Systems—Programming Language—Common Lisp, X3J13/94-101R, Version 15.17R, Fri 12-Aug-1994 6:35pm EDT; no copyright indicated.

Additional clarification and comments by Michael Marking <marking@tatanka.com>, http://www.tatanka.com/software/cl-manpages/; alternatively, https://github.com/wakinyantanka/cl-manpages/. Copyright 2017 Michael Marking as both an original and a derivative work.

Licensed under Creative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND 4.0).

This page last revised Sunday 26 February 2017.