On this page:
eval
Evaluator
Evaluator.make_  rhombus
Evaluator.make_  rhombus_  empty
Evaluator.import
Evaluator.current
8.12

6.51 Eval🔗ℹ

An evaluator is an interactive evaluation context. Each evaluator has its own set of bindings and, potentially, its own set of module declarations. A Rhombus read-eval-print loop (REPL) is backed by an evaluator, for example.

function

fun eval(seq :: Syntax,

         ~as_interaction: as_interaction :: Any = #false)

Evaluates a term, group, or multi-group sequence seq in the current evaluator.

If as_interaction is true, then seq is evaluated as if in a read-eval-print loop. Depending on the bindings of the current evaluator (as determined by Evaluator.current), that can be different that evaluating non-interaction top-level forms.

A suitable evalutor must have been created and installed as the value of the Evaluator.current context parameter, since the default evaluator is empty.

> parameterize { Evaluator.current: Evaluator.make_rhombus() }:

    eval('1 + 2')

3

annotation

Evaluator

Represents an evaluator for interactive evaluation via eval. An evaluator is installed as the current one using Evaluator.current, usually via parameterize.

Creates a fresh evaluator with rhombus imported.

Creates a fresh evaluator with the rhombus module attached, but not imported.

Imports mod into the current evaluator, even if the import definition form is not available in the evaluator itself.

A context parameter for the current evaluator.