Skip to main content

eval_main

Function eval_main 

Source
pub fn eval_main(instance: &Value, ctx: &Ctx) -> Result<Option<Value>, Raised>
Expand description

Evaluates the __main body of a module instance in its own environment. Returns Ok(None) if no body is declared (e.g., a library).

This implements “runnable” module semantics: crate::load_module instantiates modules without evaluating their bodies, ensuring __main is only executed when explicitly targeted by a runner.

The body executes in the instance’s Module terminal. As it is not a member, it has no reserved ID. Non-module instances raise .not_a_module. Result interpretation is handled by the runner; see docs/done/2026-08-14_elly-run.md.