Skip to main content

RuntimeValue

Enum RuntimeValue 

Source
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

Fields

§months: i32
§days: i32
§

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

Source

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.

Source

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.

Source

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.

Source

pub fn deep_clone(&self) -> RuntimeValue

Checks if this value evaluates to true in a boolean context.

  • Bool(true) → true
  • Int(n) → true if n ≠ 0
  • Nothing → false
  • All other values → true
Source

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.)

Source

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

Source§

fn clone(&self) -> RuntimeValue

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RuntimeValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for RuntimeValue

Source§

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).

1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for RuntimeValue

Source§

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).

1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,