pub enum Value {
}Expand description
A Scheme value
Corresponds to OpenJade’s ELObj base class.
Memory management: Uses Gc<T> for heap-allocated values.
The gc crate provides conservative garbage collection similar
to OpenJade’s Collector.
Note: We manually implement Trace/Finalize because Node and NodeList variants use Rc (not Gc) and contain trait objects.
Variants§
Nil
The empty list ()
OpenJade: NilObj
Bool(bool)
Boolean: #t or #f
OpenJade: TrueObj / FalseObj
Integer(i64)
Exact integer
OpenJade: IntegerObj (long n_)
Real(f64)
Inexact real number
OpenJade: RealObj (double n_)
Char(char)
Unicode character
OpenJade: CharObj (Char ch_)
String(Gc<String>)
Immutable string
OpenJade: StringObj (extends StringC)
Using Gc<String> for garbage collection.
Symbol(Rc<str>)
Interned symbol
OpenJade: SymbolObj (StringObj* name_)
Symbols are interned (shared) for efficiency.
Using Rc<str> since symbols are immutable and shared.
Keyword(Rc<str>)
Keyword (DSSSL extension)
OpenJade: KeywordObj
Keywords are like symbols but in a separate namespace.
Pair(Gc<GcCell<PairData>>)
Cons cell (pair)
OpenJade: PairObj (ELObj* car_, ELObj* cdr_)
Using Gc<PairData> for garbage-collected pairs.
GcCell allows mutation (for set-car!/set-cdr!).
Vector(Gc<GcCell<Vec<Value>>>)
Vector (array)
OpenJade: VectorObj (Vector<ELObj*>)
Using Gc<GcCell<Vec<Value>>> for mutable vectors.
Procedure(Gc<Procedure>)
Procedure (function)
OpenJade: FunctionObj (various subclasses)
Can be:
- Built-in primitive (Rust function)
- User-defined lambda (compiled bytecode or AST)
Node(Rc<Box<dyn Node>>)
A node in the document grove
Represents a node from the XML document tree. Corresponds to OpenJade’s node objects in the grove.
Phase 3: Now fully implemented with libxml2 grove.
Uses Rc<Box<dyn Node>> instead of Gc because:
- Nodes are owned by the grove, not the Scheme GC
- Grove lifetime is managed separately
- Trait objects can’t derive Trace automatically
NOTE: Managed by Rc, not GC - see manual Trace impl below
NodeList(Rc<Box<dyn NodeList>>)
Node list (grove query result)
Represents a collection of nodes from grove queries. Corresponds to DSSSL node-list objects.
Phase 3: Now fully implemented with libxml2 grove.
Uses Rc<Box<dyn NodeList>> for same reasons as Node.
NOTE: Managed by Rc, not GC - see manual Trace impl below
Sosofo
Sosofo (flow object sequence)
Placeholder - will be properly implemented in Phase 4.
Unspecified
Unspecified value
Returned by expressions with unspecified results (like set!).
OpenJade: UnspecifiedObj
Error
Error marker
Used internally for error propagation.
OpenJade: ErrorObj
Implementations§
Source§impl Value
impl Value
Sourcepub fn cons_with_pos(car: Value, cdr: Value, pos: Position) -> Self
pub fn cons_with_pos(car: Value, cdr: Value, pos: Position) -> Self
Create a cons cell with source position
Sourcepub fn primitive(
name: &'static str,
func: fn(&[Value]) -> Result<Value, String>,
) -> Self
pub fn primitive( name: &'static str, func: fn(&[Value]) -> Result<Value, String>, ) -> Self
Create a built-in primitive procedure
Sourcepub fn lambda(params: Vec<String>, body: Value, env: Gc<Environment>) -> Self
pub fn lambda(params: Vec<String>, body: Value, env: Gc<Environment>) -> Self
Create a user-defined lambda procedure
Sourcepub fn lambda_with_source(
params: Vec<String>,
body: Value,
env: Gc<Environment>,
source: Option<SourceInfo>,
name: Option<String>,
) -> Self
pub fn lambda_with_source( params: Vec<String>, body: Value, env: Gc<Environment>, source: Option<SourceInfo>, name: Option<String>, ) -> Self
Create a user-defined lambda procedure with source location
Source§impl Value
impl Value
Sourcepub fn equal(&self, other: &Value) -> bool
pub fn equal(&self, other: &Value) -> bool
Scheme equal? - Deep structural equality
Corresponds to OpenJade’s ELObj::equal()
Recursively compares:
- Lists and vectors: Element-wise comparison
- Strings: Content comparison
- Numbers: Numeric equality
- Everything else: Same as
eqv?
Sourcepub fn eqv(&self, other: &Value) -> bool
pub fn eqv(&self, other: &Value) -> bool
Scheme eqv? - Equivalence (same value, not necessarily same object)
Corresponds to OpenJade’s ELObj::eqv()
Returns true if:
- Both are the same boolean value
- Both are the same number (integer or real)
- Both are the same character
- Both are the same symbol (symbols are interned)
- Both are the same keyword
- Both refer to the same pair/vector/procedure object
- Both are nil
Source§impl Value
impl Value
Sourcepub fn is_true(&self) -> bool
pub fn is_true(&self) -> bool
Is this true? (for conditionals)
In Scheme, only #f is false; everything else (including nil) is true.
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Is this an integer?
Sourcepub fn is_procedure(&self) -> bool
pub fn is_procedure(&self) -> bool
Is this a procedure?
Sourcepub fn is_node_list(&self) -> bool
pub fn is_node_list(&self) -> bool
Is this a node list?
Trait Implementations§
Source§impl Finalize for Value
Manual implementation of Finalize for Value
impl Finalize for Value
Manual implementation of Finalize for Value
No finalization needed - all cleanup is handled by Drop impls
Source§impl Trace for Value
Manual implementation of Trace for Value
impl Trace for Value
Manual implementation of Trace for Value
We implement this manually because:
- Node and NodeList use Rc<Box
>, which doesn’t implement Trace - These are managed by Rc, not the GC
- All other variants use Gc and need proper tracing
Source§fn finalize_glue(&self)
fn finalize_glue(&self)
Finalize::finalize() on this object and all
contained subobjects