pub struct Ctx { /* private fields */ }Expand description
The thin evaluation context threaded through the tree-walker: the unique-id
source (closure identities) and the builtin module cache. It carries no
module registry and no loader — a module’s imports are resolved before
evaluation begins (see crate::load_module), and a loaded module is an
ordinary Rc-held value, kept alive only by whatever holds it.
Implementations§
Source§impl Ctx
impl Ctx
Sourcepub fn with_ids(ids: u64) -> Self
pub fn with_ids(ids: u64) -> Self
A context resuming an id source at ids, so identities it mints
continue where an earlier context left off.
A host that builds a fresh Ctx per call and hands values out between
them — the Python bindings do exactly this — needs it: a module reserves
its item id block when it is instantiated (see instantiate), and the
programs that later use it mint closure ids from a different context. If
both started at zero, an item and an unrelated closure would get the same
id and __eq would call them equal. The host reads
ids_used back when the context is done and seeds the
next one with it.
The counter is carried by value rather than shared behind an Rc: the
pointer chase it would add to every closure mint costs ~2% on fib_naive,
and only the host needs the continuity.