pub struct ModuleData { /* private fields */ }Expand description
A loaded module: an immutable table of unevaluated item bodies
(“dehydrated code”), sorted by name. Built once by crate::compile_module
and then frozen behind an Rc. Sibling references inside the bodies are
compiled to Expr::ModItem — a sink resolved through the home module carried
in the environment (EnvNode::Module), not through any registry — so a
ModuleData owns nothing but Exprs and never points back at a value, and
the value heap stays acyclic. See docs/done/2026-08-07_elly-modules-v0.md.
A sibling reference reaches its body by index (a direct slice index, the hot
path); an outside M.name access, which has only a name, binary-searches.
Implementations§
Source§impl ModuleData
impl ModuleData
Sourcepub fn item_names(&self) -> Vec<&Text>
pub fn item_names(&self) -> Vec<&Text>
The module’s item names, in sorted order — its public listing, and the
only names an outside M.name access can reach.
Sourcepub fn local_names(&self) -> Vec<&Text>
pub fn local_names(&self) -> Vec<&Text>
The names the module declares with local, in sorted order. A local
appears here and nowhere else — it is not an item, so it is not reachable
as M.name from outside — which is the same shape a private
iota has, and it is offered for the same reason: a
host’s introspection (a debugger, a const stage) wants to see what a
module declares, while the language gives no way to reach it.
Sourcepub fn iota_names(&self) -> &[Text]
pub fn iota_names(&self) -> &[Text]
The names the module declares with const, in sorted order. A private
iota appears here and nowhere else — it is not an item, so it is not
reachable as M.name from outside.
Sourcepub fn frame_names(&self) -> &[Text]
pub fn frame_names(&self) -> &[Text]
The names of the module’s frame slots, in slot order — what it must be
instantiated against (see instantiate). Empty for a module with no
frame.
Sourcepub fn imports(&self) -> &[ImportSpec]
pub fn imports(&self) -> &[ImportSpec]
The specs of the module’s imports, in slot order: imports()[i] is what
frame_names()[i] was imported from. The list is a static, auditable
account of every module this one can reach, readable without running
anything — which is the point of writing an import rather than calling a
loader.
Sourcepub fn body(&self) -> Option<&Expr>
pub fn body(&self) -> Option<&Expr>
The module’s body, if it has one: a recur group’s body, or
the __main a source declared. A runner reads it here and evaluates it in
the instance’s own environment (see crate::eval_main); everything else
leaves it alone, which is what makes an imported __main inert.
Sourcepub fn name(&self) -> Option<&ModuleName>
pub fn name(&self) -> Option<&ModuleName>
The canonical name the module’s code came from, when a host named it —
what __Mod.name reports and what the const stage deduplicates instances
by. None for code no host named.
Trait Implementations§
Source§impl Debug for ModuleData
impl Debug for ModuleData
Source§impl PartialEq for ModuleData
impl PartialEq for ModuleData
Source§fn eq(&self, other: &ModuleData) -> bool
fn eq(&self, other: &ModuleData) -> bool
self and other values to be equal, and is used by ==.