Skip to main content

Module value

Module value 

Source
Expand description

Value type for the Bop interpreter.

Heap-allocating variants use newtypes with private fields. The only way to construct them is through the tracked constructors (Value::new_str, Value::new_array, Value::new_dict), which call bop_alloc. This is enforced by the type system — code outside this module cannot access the private inner fields.

Structs§

BopArray
BopDict
BopEnumVariant
A user-defined enum variant value — the concrete data side of Bop’s sum types. Like BopStruct, it’s identified by the (module_path, type_name) pair, plus the selected variant’s name and payload. Two enums declared in different modules with the same type name and even the same variants still compare as distinct types.
BopFn
A Bop function value — the runtime representation of a closure or a reified fn foo(...) { ... } declaration. Shared by Rc so first-class usage (let g = f; pass(f)) is cheap.
BopModule
Exported surface of a module, as presented through an aliased use statement. Rc<BopModule> is what a Value::Module carries so cloning the Value stays cheap.
BopStr
BopStruct
A user-defined struct value. Carries the module it was declared in plus the bare type name, so two modules that happen to declare struct Color { ... } independently produce distinct values even when they share a name. The module path is <root> for the top-level program and <builtin> for engine-registered builtins like RuntimeError; for user modules it’s the dot-joined use path ("std.math", "game.entity", …). Fields are stored in declaration order so iteration and Display stay stable.

Enums§

BopIter
Built-in lazy iterator shapes. Each one holds a snapshot of the source sequence plus a cursor; advancing via Self::next yields items until exhausted. A user-defined iterator doesn’t need to live here — it’s just a struct with a .next() method, dispatched through the ordinary method path.
EnumPayload
Runtime payload attached to a BopEnumVariant. Mirrors the three variant shapes the parser recognises (VariantKind::{Unit, Tuple, Struct}).
FnBody
Engine-specific representation of a function body.
Value

Constants§

BUILTIN_MODULE_PATH
Module path used for engine-registered builtins (Result, RuntimeError). Surfaces wherever a struct / enum value needs to carry its declaring module; the engines all agree on this literal so patterns + equality line up across walker / VM / AOT.
ROOT_MODULE_PATH
Module path used for types declared directly in the program root (not in any imported module). Same literal across every engine.

Functions§

values_equal