Requesting Evaluation

Evaluation of an expression can be explicitly requested using the function eval. (eval x ) gives the result of evaluating the value of the expression x: eval performs an extra level of evaluation. The argument of eval is evaluated to produce some Lisp code; then eval causes that Lisp code to be evaluated.

(define formula '(* 3.14159 (expt radius 2)))

(eval (subst 10.0 'radius formula)) = 314.159

eval allows Lisp code to create new Lisp functions:

(define (define-alias new old)
  (eval (list 'define new old)) )

> (define-alias 'rest 'cdr) > (rest '(a b c)) (b c)

Contents    Page-10    Prev    Next    Page+10    Index