Lisp Evaluator
A Lisp evaluator with fully trampolined evaluation - no Rust stack recursion, enabling unlimited recursion depth (bounded only by heap/arena size).
Key Features
- Full Trampolining: All evaluation uses continuation-passing style with an explicit continuation stack. No Rust recursion means no stack overflow.
- Strict Evaluation: Call-by-value semantics - all arguments are evaluated before function application
- Proper TCO: Tail calls reuse the same continuation frame
- Lexically Scoped Closures: First-class functions with captured environments
- Rich Error Handling: Error messages with stack traces
- Pattern Matching:
casefor value matching - Iteration:
doloops for imperative-style iteration - Meta-programming:
evalfor runtime code evaluation,quasiquote/unquote - Mutation:
set!,set-car!,set-cdr!for imperative programming
Evaluation Strategy
This evaluator uses strict (call-by-value) evaluation:
- All function arguments are fully evaluated before the function is called
- This provides predictable evaluation order and side-effect timing
- Tail call optimization is supported for constant-space recursion
Mutation
This Lisp supports mutation operations for imperative programming:
set!- Mutate a variable bindingset-car!- Mutate the car of a cons cellset-cdr!- Mutate the cdr of a cons cell
Note: Mutation breaks referential transparency but enables imperative patterns.
Truthiness
Only #f is false. Everything else (including the empty list '()) is truthy.
Special Forms
quote- Return expression unevaluatedif- Conditionalcond- Multi-way conditionalcase- Pattern matching on valueslambda- Create closuredefine- Define variable/functionset!- Mutate variable bindinglet- Local bindinglet*- Sequential local bindingbegin- Sequence of expressionsand/or- Short-circuit boolean operationsdo- Iteration with initialization and step expressionsquasiquote- Template withunquoteandunquote-splicingeval- Evaluate expression at runtimeapply- Apply function to argument listvalues- Return multiple values as a list