pub enum Val {
Cst(i64),
Sym(SmolStr),
Tup(RcVal, RcVal),
Clo(Env, RcExp),
Nil,
Code(RcExp),
Cell(usize),
}Expand description
Variants§
Cst(i64)
Integer constant (also the boolean encoding: 0 false, 1 true).
Sym(SmolStr)
Symbol. SmolStr is O(1) clone for strings ≤22 bytes.
Tup(RcVal, RcVal)
Cons cell. Rc<Val> makes car/cdr O(1) — Pink source lists are
traversed many times during staging.
Clo(Env, RcExp)
Closure: environment + body.
Both are Rc for O(1) clone and ptr_eq in find_fun.
Nil
The empty list, terminating every Val::Tup chain. Note that
if does not accept it as a condition — conditions are numbers
(or code); test for nil with null?.
Code(RcExp)
Staged code value. Rc<Exp> — shared through the staging machinery.
Cell(usize)
First-class mutable cell — an index into EvalCtx.cells (the
per-instance, in-process store: each evaluator owns its own
heap, so instances snapshot and compose freely). Identity
is the index: eq? compares indices, cell-set! through one alias
is visible through all. Cells never fold under staging: lift
of a Cell errors, and staged cell ops residualize as operations.
Implementations§
Source§impl Val
impl Val
Sourcepub fn short_desc(&self) -> String
pub fn short_desc(&self) -> String
Compact description suitable for error messages. Avoids dumping
large Val::Code trees — instead reports node count.
This is the form to use in NarjuError::TypeError.actual and
similar diagnostic strings. Use display(v) (in eval/mod.rs)
or format!("{v}") (via fmt::Display) for user-facing output
where the full structure matters.