chickadee » scheme » eval

eval expression #!optional environment-specifierprocedure

Evaluates expression in the specified environment and returns its value. Expression must be a valid Scheme expression represented as data, and environment-specifier must be a value returned by one of the three procedures described below. Implementations may extend eval to allow non-expression programs (definitions) as the first argument and to allow other values as environments, with the restriction that eval is not allowed to create new bindings in the environments associated with null-environment or scheme-report-environment.

(eval '(* 7 3) (scheme-report-environment 5))
                                                           ===>  21

(let ((f (eval '(lambda (f x) (f x x))
               (null-environment 5))))
  (f + 10))
                                                           ===>  20

The environment-specifier is optional, and if not provided it defaults to the value of (interaction-environment). This is a CHICKEN extension to R5RS, which, though strictly nonportable, is very common among Scheme implementations.