pub enum RuntimeValue {
Show 32 variants
Int(i64),
BigInt(Rc<BigInt>),
Rational(Rc<Rational>),
Decimal(Rc<Decimal>),
Complex(Rc<Complex>),
Modular(Rc<Modular>),
Float(f64),
Bool(bool),
Text(Rc<String>),
Char(char),
List(Rc<RefCell<ListRepr>>),
Tuple(Rc<Vec<RuntimeValue>>),
Set(Rc<RefCell<Vec<RuntimeValue>>>),
Map(Rc<RefCell<MapStorage>>),
Struct(Box<StructValue>),
Inductive(Box<InductiveValue>),
Function(Box<ClosureValue>),
Nothing,
Duration(i64),
Date(i32),
Moment(i64),
Span {
months: i32,
days: i32,
},
Time(i64),
Chan(ChanId),
TaskHandle(TaskId),
Peer(Rc<String>),
Crdt(Rc<RefCell<CrdtValue>>),
Word(WordVal),
Lanes(Rc<LanesVal>),
Quantity(Rc<QuantityValue>),
Money(Rc<Money>),
Uuid(Rc<Uuid>),
}Variants§
Int(i64)
BigInt(Rc<BigInt>)
An exact integer that does NOT fit i64 — the overflow-safe continuation of
Int. INVARIANT: b.to_i64().is_none() always holds (build via
RuntimeValue::from_bigint, which downsizes any in-range result back to
Int), so there is exactly one representation per integer value and Eq/
Hash/ordering never need a cross-Int arm. Rc keeps Clone O(1).
Rational(Rc<Rational>)
An exact rational number — the result of an integer division that does NOT
divide evenly (7 / 2 → 7/2), the way Int “overflows” into BigInt.
INVARIANT: never a whole number — build via RuntimeValue::from_rational,
which downsizes an integer-valued rational to Int/BigInt, so a value has
one canonical representation and Eq/Hash need no cross-Int arm.
Decimal(Rc<Decimal>)
An exact base-10 fixed-point number — money’s type. Distinct from Rational:
it carries a scale (decimal places) for faithful display (19.99, not
1999/100), and unlike Int/BigInt/Rational it does NOT downsize on a
whole value (20.00 stays Decimal, not Int), because the scale is meaning.
+ − × are exact and keep it Decimal; ÷ and a Rational operand promote to
the exact Rational (base-10 division need not terminate). Rc keeps Clone O(1).
Complex(Rc<Complex>)
An exact complex number re + im·i, each part a Rational. The field that closes
the tower for √ of a negative and for EE/signal math: i·i = −1 exactly. NOT
ordered (complex numbers have no total order), so it never appears in compare.
Modular(Rc<Modular>)
An element of the ring ℤ/nℤ — an integer modulo a fixed modulus (the arbitrary-modulus
generalisation of Word). Arithmetic wraps into [0, modulus); the crypto/number-theory
substrate (modular exponentiation, inverse). Equal only at the same value AND modulus.
Float(f64)
Bool(bool)
Text(Rc<String>)
Char(char)
List(Rc<RefCell<ListRepr>>)
Tuple(Rc<Vec<RuntimeValue>>)
Set(Rc<RefCell<Vec<RuntimeValue>>>)
Map(Rc<RefCell<MapStorage>>)
Struct(Box<StructValue>)
Inductive(Box<InductiveValue>)
Function(Box<ClosureValue>)
Nothing
Duration(i64)
Date(i32)
Moment(i64)
Span
Time(i64)
Chan(ChanId)
A channel handle (a Pipe) — an opaque token into the scheduler.
TaskHandle(TaskId)
A spawned-task handle — an opaque token into the scheduler.
Peer(Rc<String>)
A remote peer handle — its canonical relay topic. Send … to <peer>
publishes on this topic; the peer receives it on its own inbox.
Crdt(Rc<RefCell<CrdtValue>>)
A live CRDT (observed-remove set, replicated sequence, or multi-value register)
held by the tree-walker. Wraps the real logicaffeine_data type the compiled tier
uses, so merge converges identically across tiers. Rc<RefCell<_>> gives the same
interior-mutation/aliasing semantics as Set/List/Map, so mutating a struct’s
CRDT field through a field access updates the shared value in place.
Word(WordVal)
A fixed-width wrapping integer (Word32/Word64) — the ring ℤ/2ᵏ the bit-twiddling
primitives (ChaCha20 over Word32, Keccak over Word64) compute over. Distinct from
Int: its arithmetic wraps and it never promotes to BigInt.
Lanes(Rc<LanesVal>)
A SIMD lane vector (Lanes8Word32 = 8×Word32 = one __m256i) — a fixed-width vector over
the Word ring. The tree-walker carries the scalar-lane representation and computes each op as
independent scalar lanes (the spec); AOT lowers the same op to an AVX2 intrinsic. Boxed in Rc
so the 256-bit lane payload stays out of the 16-byte RuntimeValue (the NaN-box invariant).
Quantity(Rc<QuantityValue>)
A physical quantity — an exact magnitude carrying a Dimension and a display unit
(2 inches, 9.8 m/s²). The magnitude rides the exact rational tower, so unit conversion
is lossless (2 inches + 5 cm in feet = 42/127 ft); + − and comparison require the SAME
dimension (else a typed error, like Word width-mismatch), × ÷ combine dimensions. The
display unit travels with the value so Show renders it faithfully.
Money(Rc<Money>)
An exact monetary amount in a currency (19.99 USD). The amount rides the Decimal tower so it
never float-drifts; + − and comparison require the SAME currency (else a typed error, like a
dimension mismatch), × ÷ scale by a number. The currency travels with the value.
Uuid(Rc<Uuid>)
A 128-bit UUID (RFC 9562). Ord by bytes — so v6/v7 ids sort chronologically — and a stable
canonical text form. Rc-boxed to keep RuntimeValue at 16 bytes (the value itself is a
Copy [u8;16]; the compiled tier carries it unboxed).
Implementations§
Source§impl RuntimeValue
impl RuntimeValue
Sourcepub fn from_bigint(b: BigInt) -> RuntimeValue
pub fn from_bigint(b: BigInt) -> RuntimeValue
Build an integer value from a BigInt, DOWNSIZING to RuntimeValue::Int
whenever the value fits i64. This is the single chokepoint that maintains
the BigInt-is-always-out-of-range invariant, so every integer has one
canonical representation — the “downsize when it provably fits” rule, applied
unconditionally on every result.
Sourcepub fn from_rational(r: Rational) -> RuntimeValue
pub fn from_rational(r: Rational) -> RuntimeValue
Build a number from a Rational, DOWNSIZING to an exact integer
(Int/BigInt) whenever the denominator reduces to 1. This is the single
chokepoint that maintains the Rational-is-never-whole invariant, so an
integer-valued result (6 / 2 → 3) is an Int, not a Rational — exactly the
“downsize when it provably fits” rule from_bigint applies for integers.
Sourcepub fn type_name(&self) -> &str
pub fn type_name(&self) -> &str
Returns the type name of this value as a string slice.
Used for error messages and type checking at runtime.
Sourcepub fn deep_clone(&self) -> RuntimeValue
pub fn deep_clone(&self) -> RuntimeValue
Checks if this value evaluates to true in a boolean context.
Bool(true)→ trueInt(n)→ true if n ≠ 0Nothing→ false- All other values → true
Sourcepub fn is_truthy(&self) -> bool
pub fn is_truthy(&self) -> bool
Falsy: false, numeric zero (Int/Float/BigInt/Rational/Decimal/Complex/Word),
nothing, and empty Text/List/Set/Map. Everything else is truthy.
(-0.0 is zero; NaN is nonzero and therefore truthy.)
Sourcepub fn to_display_string(&self) -> String
pub fn to_display_string(&self) -> String
Converts this value to a human-readable string for display.
Used by the show() built-in function and for debugging output.
Formats collections with brackets, structs with field names, and
inductive values with constructor notation.
Trait Implementations§
Source§impl Clone for RuntimeValue
impl Clone for RuntimeValue
Source§fn clone(&self) -> RuntimeValue
fn clone(&self) -> RuntimeValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RuntimeValue
impl Debug for RuntimeValue
Source§impl Hash for RuntimeValue
impl Hash for RuntimeValue
Source§fn hash<H: Hasher>(&self, state: &mut H)
fn hash<H: Hasher>(&self, state: &mut H)
The hash/equality coherence law: values that compare equal MUST hash
equal. Numeric types are cross-type equal (1 == 1.0 == 1/1), so they
share ONE hash stream — the unified numeric hash (value mod 2^61 − 1,
base::numeric) with NO discriminant prefix. Everything else keeps
its discriminant-prefixed per-type hash (collisions between UNEQUAL
values are always allowed; only equal ⇒ equal-hash is required).
Source§impl PartialEq for RuntimeValue
impl PartialEq for RuntimeValue
Source§fn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
ONE equality: delegates to crate::semantics::compare::values_equal,
so map-key lookup, set membership, and the language’s == can never
disagree. Structural for collections/structs, EXACT across numeric
types (1 == 1.0), IEEE for floats — coherent with the unified
numeric Hash below (equal values hash equal).
impl Eq for RuntimeValue
NOTE: eq is IEEE on floats, so NaN != NaN — strictly this bends Eq’s
reflexivity for the one value IEEE defines as not equal to itself. The
trade is deliberate: map keys behave exactly like the language’s own ==
(a NaN key is unfindable, as IEEE intends) instead of maps and ==
silently disagreeing about float identity. Everything else is a total
equivalence.
Auto Trait Implementations§
impl Freeze for RuntimeValue
impl !RefUnwindSafe for RuntimeValue
impl !Send for RuntimeValue
impl !Sync for RuntimeValue
impl Unpin for RuntimeValue
impl UnsafeUnpin for RuntimeValue
impl !UnwindSafe for RuntimeValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.