pub enum Value {
Show 13 variants
Nil,
Boolean(bool),
Number(isize),
Symbol(ArenaIndex),
Cons {
car: ArenaIndex,
cdr: ArenaIndex,
},
String {
len: usize,
data: ArenaIndex,
},
Char(char),
Operative {
params_envparam: ArenaIndex,
body_env: ArenaIndex,
},
Applicative(ArenaIndex),
Builtin(BuiltinId),
Environment {
bindings: ArenaIndex,
parents: ArenaIndex,
},
Inert,
Ignore,
}Expand description
A Lisp value stored in the arena. Variants can only inline max two arenaindex sized data.
Variants§
Nil
The empty list / nil.
Boolean(bool)
Number(isize)
Integer number.
Symbol(ArenaIndex)
A symbol, pointing to a String value that holds the name.
Cons
A cons cell (pair) with inline car and cdr.
String
A string with inline length and pointer to character data.
Char(char)
A character.
Operative
Compound operative (vau closure / fexpr).
Created by (vau params env-param body).
params_envparam = (params . env-param), body_env = (body . closed-env)
Applicative(ArenaIndex)
Applicative wrapper: evaluates arguments, then calls inner combiner.
Created by (wrap combiner). The inner combiner is any callable:
Operative, Builtin, or even another Applicative.
Builtin(BuiltinId)
Rust-native primitive operative. Always an operative — receives unevaluated args + caller env. Applicative primitives (like +) are (wrap (Builtin id)) at init time.
Environment
A first-class environment with lexical parent chain.
bindings: alist of (symbol . value) pairs in this frame.
parents: cons-list of parent environments, or NIL for top-level.
Inert
The inert value, written #inert.
Returned by combiners whose primary purpose is side-effect (e.g. $define!).
Ignore
The ignore value, written #ignore.
Used specifically for parameter matching in formal parameter trees.
Implementations§
Source§impl Value
impl Value
Sourcepub fn type_name(&self) -> &'static str
pub fn type_name(&self) -> &'static str
Returns the type name as a static string (for error messages).
Sourcepub fn is_self_evaluating(self) -> bool
pub fn is_self_evaluating(self) -> bool
True for self-evaluating forms (literals, closures, builtins).
Self-evaluating values exclude symbols and cons cells (which require lookup / dispatch).
Sourcepub fn is_immutable(self) -> bool
pub fn is_immutable(self) -> bool
True for immutable, encapsulated types whose identity is
determined by value rather than arena slot (used by eq?).
Sourcepub fn as_number(self) -> Result<isize, ArenaError>
pub fn as_number(self) -> Result<isize, ArenaError>
Extract the numeric value, or Err(TypeError) if not a number.
Sourcepub fn as_cons(self) -> Result<(ArenaIndex, ArenaIndex), ArenaError>
pub fn as_cons(self) -> Result<(ArenaIndex, ArenaIndex), ArenaError>
Extract the car and cdr of a cons cell.
Sourcepub fn as_symbol(self) -> Result<ArenaIndex, ArenaError>
pub fn as_symbol(self) -> Result<ArenaIndex, ArenaError>
Extract the symbol’s string index.
Sourcepub fn as_bool(self) -> Result<bool, ArenaError>
pub fn as_bool(self) -> Result<bool, ArenaError>
Extract the boolean value, or Err(TypeError) if not a boolean.
Sourcepub fn as_applicative(self) -> Result<ArenaIndex, ArenaError>
pub fn as_applicative(self) -> Result<ArenaIndex, ArenaError>
Extract the inner combiner of an applicative, or Err(TypeError).
Trait Implementations§
Source§impl<const N: usize> Trace<Value, N> for Value
impl<const N: usize> Trace<Value, N> for Value
Source§fn trace<F: FnMut(ArenaIndex)>(&self, tracer: F)
fn trace<F: FnMut(ArenaIndex)>(&self, tracer: F)
ArenaIndex references contained in this value. Read more