Requesting Evaluation

Evaluation of an s-expression can be explicitly requested using the function EVAL. (EVAL x) gives the result of evaluating the value of the expression x in the current execution context. That is, EVAL performs an extra level of evaluation. The argument of EVAL is evaluated once, and should return as its value some Lisp code; then EVAL causes that Lisp code to be evaluated.


(EVAL (LIST 'LIST (LIST 'QUOTE 'A)))
                     = (A)

(EVAL (SUBST 10.0 'RADIUS
          '(* 3.14159 (EXPT RADIUS 2))))

                     =  314.159
EVAL and its relatives allow Lisp code to be part of a data structure; the code can be retrieved from the data structure and executed by calling EVAL.

Contents    Page-10    Prev    Next    Page+10    Index