Expand description
Scheme evaluator (eval loop)
Ported from OpenJade’s Interpreter.cxx (~2,000 lines).
§Core Responsibilities
- Evaluate expressions - Transform Values into results
- Special forms - Handle if, let, define, lambda, quote, etc.
- Function application - Call procedures with arguments
- Tail call optimization - Prevent stack overflow in recursive functions
§OpenJade Correspondence
| Dazzle | OpenJade | Purpose |
|---|---|---|
Evaluator | Interpreter | Main evaluator state |
eval() | Interpreter::eval() | Core eval loop |
apply() | Interpreter::apply() | Function application |
eval_special() | Interpreter::evalXXX() | Special form handlers |
§Evaluation Rules (R4RS)
- Self-evaluating: Numbers, strings, booleans, characters → return as-is
- Symbols: Look up in environment
- Lists: First element determines behavior:
- Special form keyword → handle specially
- Otherwise → evaluate all elements, apply first to rest
Structs§
- Call
Frame - A call stack frame
- Construction
Rule - Construction rule for DSSSL processing
- Eval
Error - Evaluation error with call stack
- Evaluator
- Scheme evaluator
- Evaluator
Context - Context available to primitives during evaluation
- Processing
Mode - Processing mode containing construction rules
Functions§
- get_
evaluator_ context - Get the current evaluator context (for use in primitives)