pub enum Value {
Show 18 variants
Void,
Scalar(f64),
Matrix(Box<Array2<f64>>),
ComplexMatrix(Box<Array2<Complex<f64>>>),
Complex(f64, f64),
Str(String),
StringObj(String),
Lambda(Box<LambdaFn>),
Function(Box<FunctionData>),
Tuple(Vec<Value>),
Cell(Box<Vec<Value>>),
Struct(Box<IndexMap<String, Value>>),
StructArray(Box<Vec<IndexMap<String, Value>>>),
DateTime(f64),
Duration(f64),
DateTimeArray(Vec<f64>),
DurationArray(Vec<f64>),
Map(Box<IndexMap<String, Value>>),
}Expand description
A value held in the variable environment.
Variants§
Void
No display value — returned by side-effectful functions like fprintf.
Scalar(f64)
A single real number.
Matrix(Box<Array2<f64>>)
A 2-D real matrix (row-major). Scalars are represented as 1×1 matrices
only when produced by matrix operations; standalone numbers use Scalar.
ComplexMatrix(Box<Array2<Complex<f64>>>)
A 2-D complex matrix (row-major). Used when any element has a non-zero imaginary part.
Produced by complex matrix literals, FFT output, or mixed real/complex arithmetic. Workspace save skips this type (same policy as all non-scalar types).
Complex(f64, f64)
Complex number re + im*i.
Str(String)
Character array (single-quoted string). Represents a 1×N row of char values.
StringObj(String)
String object (double-quoted string).
Lambda(Box<LambdaFn>)
Anonymous function: @(params) expr. Stores a pre-compiled closure
that captures the lexical environment at definition time.
Function(Box<FunctionData>)
Named user-defined function: function [outputs] = name(params) ... end.
The body is stored as raw source text and re-parsed on each call.
Named functions execute in an isolated scope (only params are visible,
plus built-in constants i, j).
All fields are stored in a Boxed FunctionData to keep Value at 32 bytes.
Tuple(Vec<Value>)
Multiple return values from a multi-output function call (internal use).
Produced by calling a function with outputs.len() > 1.
Consumed by Stmt::MultiAssign in exec.rs. Not directly user-visible.
Cell(Box<Vec<Value>>)
Heterogeneous 1-D container: each element may be any Value.
Created with {1, 'hello', [1 2 3]} syntax. Indexed with c{i} (1-based).
2-D cell arrays are deferred; all cells are flat Vec<Value> for now.
Struct(Box<IndexMap<String, Value>>)
Scalar struct: ordered field map, field names preserved in insertion order.
Created with s.field = val or struct('k', v, ...).
Fields can hold any Value, including nested structs.
StructArray(Box<Vec<IndexMap<String, Value>>>)
1-D array of structs (all sharing the same field schema).
Created with s(i).field = val (1-based). Indexed with s(i) which returns
a Value::Struct. s.field collects the field across all elements.
DateTime(f64)
A UTC timestamp: seconds since 1970-01-01 00:00:00 UTC.
f64::NAN represents the NaT (Not-a-Time) sentinel.
Duration(f64)
An elapsed duration stored as a fractional number of seconds.
May be negative (e.g. t1 - t2 when t1 < t2).
DateTimeArray(Vec<f64>)
An ordered sequence of UTC timestamps (seconds since epoch).
Each element follows the same NaT-as-NaN convention as Value::DateTime.
DurationArray(Vec<f64>)
An ordered sequence of elapsed durations (seconds, fractional).
Map(Box<IndexMap<String, Value>>)
String-keyed associative array (containers.Map semantics).
Keys are always String; values may be any Value. Preserves
insertion order (via IndexMap). Indexed with m('key') and
assigned with m('key') = val.