#[repr(C)]pub enum Value {
Int(i64),
Float(f64),
Bool(bool),
String(SeqString),
Variant(Arc<VariantData>),
Map(Box<HashMap<MapKey, Value>>),
Quotation {
wrapper: usize,
impl_: usize,
},
Closure {
fn_ptr: usize,
env: Arc<[Value]>,
},
Channel(Arc<ChannelData>),
}Expand description
Value: What the language talks about
This is pure data with no pointers to other values. Values can be pushed on the stack, stored in variants, etc. The key insight: Value is independent of Stack structure.
§Memory Layout
Using #[repr(C)] ensures a predictable C-compatible layout:
- Discriminant (tag) at offset 0
- Payload data follows at a fixed offset
This allows compiled code to write Values directly without FFI calls, enabling inline integer/boolean operations for better performance.
Variants§
Int(i64)
Integer value
Float(f64)
Floating-point value (IEEE 754 double precision)
Bool(bool)
Boolean value
String(SeqString)
String (arena or globally allocated via SeqString)
Variant(Arc<VariantData>)
Variant (sum type with tagged fields) Uses Arc for O(1) cloning - essential for recursive data structures
Map(Box<HashMap<MapKey, Value>>)
Map (key-value dictionary with O(1) lookup) Keys must be hashable types (Int, String, Bool)
Quotation
Quotation (stateless function with two entry points for calling convention compatibility)
- wrapper: C-convention entry point for calls from the runtime
- impl_: tailcc entry point for tail calls from compiled code (enables TCO)
Fields
Closure
Closure (quotation with captured environment) Contains function pointer and Arc-shared array of captured values. Arc enables TCO: no cleanup needed after tail call, ref-count handles it.
Fields
Channel(Arc<ChannelData>)
Channel (MPMC sender/receiver pair for CSP-style concurrency) Uses Arc for O(1) cloning - duplicating a channel shares the underlying handles. Send/receive operations use the handles directly with zero mutex overhead.