Next: , Previous: , Up: Scheme reference   [Contents][Index]


4.13 Evaluation

Hoot is an ahead-of-time, whole-program compiler, but what if we want to evaluate arbitrary Scheme code at runtime? Fortunately, the (hoot eval) module provides a Scheme interpreter for this purpose!

Evaluation happens in the context of an environment. Here’s a simple example:

(use-modules (hoot eval) (hoot interaction-environment))
(eval '(let ((x 1) (y 2)) (+ x y)) (interaction-environment))
Procedure: eval exp toplevel-env

Evaluate exp in the context of the environment toplevel-env.

Syntax: current-environment

Expands to code that creates an evaluation environment containing all of the available top-level bindings at the location where (current-environment) is used.

Procedure: make-empty-environment

Return an empty evaluation environment.

The (hoot interaction-environment) module provides a simple environment containing all of Guile’s default bindings.

Procedure: interaction-environment

Return a basic evaluation environment with all of Guile’s default top-level bindings.