pub enum Value {
Void,
Scalar(f64),
Matrix(Array2<f64>),
Complex(f64, f64),
Str(String),
StringObj(String),
Lambda(LambdaFn),
Function {
outputs: Vec<String>,
params: Vec<String>,
body_source: String,
locals: IndexMap<String, Value>,
doc: Option<String>,
},
Tuple(Vec<Value>),
Cell(Vec<Value>),
Struct(IndexMap<String, Value>),
StructArray(Vec<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(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.
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(LambdaFn)
Anonymous function: @(params) expr. Stores a pre-compiled closure
that captures the lexical environment at definition time.
Function
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).
Fields
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(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(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(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.