pub enum Value {
Number(i64),
Symbol(String),
String(String),
Bool(bool),
List(Vec<Value>),
PrecompiledOp {
op: &'static BuiltinOp,
op_id: String,
args: Vec<Value>,
},
BuiltinFunction {
id: String,
func: fn(&[Value]) -> Result<Value, Error>,
},
Function {
params: Vec<String>,
body: Box<Value>,
env: Environment,
},
Unspecified,
}Expand description
Core AST type in interpreter
Note: PrecompiledOps (optimized s-expressions) don’t equality-compare to dynamically generated unoptimized s-expressions. However, since no expression can return a PrecompiledOp (they’re consumed during evaluation), this is not a concern for user code.
To build an AST, use the ergonomic helper functions:
val(42)for values,sym("name")for symbols,nil()for empty listsval([1, 2, 3])for homogeneous listsval(vec![sym("op"), val(42)])for mixed lists
Variants§
Number(i64)
Numbers (integers only)
Symbol(String)
Symbols (identifiers)
String(String)
String literals
Bool(bool)
Boolean values
List(Vec<Value>)
Lists (including proper and improper lists, empty list represents nil)
PrecompiledOp
Pre-compiled operations with their arguments (optimized during parsing)
BuiltinFunction
Built-in functions (used when called through Symbol, not pre-optimized due to dynamism) Uses id string for equality comparison instead of function pointer
Function
User-defined functions (params, body, closure env)
Unspecified
Unspecified values (e.g., return value of define) These values never equal themselves or any other value