Skip to content

Interpreter

opulse.definition.interpreter

Reference interpreter: the executable form of docs/reference/semantics.md (section 4-5).

It evaluates definitions by walking their syntax trees and shares nothing with :mod:opulse.definition.codegen except the AST and the base operations of :class:~opulse.core.semantics.Semantics. Compiled code is checked against it. It deliberately does no caching or sharing: every occurrence is evaluated, in the order the specification prescribes.

EngineError

Bases: RuntimeError

The engine broke an invariant (for example unbounded recursion). Never data.

ReferenceInterpreter

forget

forget(func_id: str) -> None

Drop cached results of this operator and of every operator that applies it, directly or through other operators (their values may change with its definition).

evaluate

evaluate(operator, args: tuple) -> Result

Value and counts of operator(*args); the call itself is not counted.

evaluate_expr

evaluate_expr(node: Expr, env: dict[str, object]) -> Result

Value and counts of a free-standing expression (section 6).

run_with_deep_stack

run_with_deep_stack(fn, *args)

Retry a bounded evaluation on one reusable thread with a larger stack.