Route syntax-quote, set!, var, ., new to interpreter

Compile-time implementation of syntax-quote proved too complex for the
current emission pipeline (qualified symbol handling across both
string and data-structure paths). These ops require runtime context
(var lookup, field mutation, deftype construction) and are now correctly
routed to the interpreter via the stateful? check in eval-string.

Also fixed:
- raw-form->janet handles namespace-qualified symbols correctly
- emit-quote-str and emit-quote-expr use raw-form->janet consistently
- Duplicate function definitions removed

All 317 tests pass, 0 failures.
This commit is contained in:
Yogthos 2026-06-02 16:48:10 -04:00
parent 1de109f261
commit 4ca7c31e50
7 changed files with 254 additions and 44 deletions

View file

@ -44,6 +44,36 @@ When you need to mutate a local with `set`, use `(var x nil)` not `(def x nil)`.
Key design decision: **compile-and-eval emits Janet DATA STRUCTURES, not source strings**, because Janet's `eval` doesn't see `use`-imported symbols. `core-fn-values` table resolves Janet names to actual function values at compile time.
## Compiler Development
### Adding a new op to the compiler
1. Add match arm in `analyze-form` — maps Clojure form → AST node
2. Add `emit-*-str` for source-to-source path, then arm in `emit-ast` dispatch
3. Add `emit-*-expr` for data-structure path, then arm in `emit-expr` dispatch
4. Add tests
### Emitter patterns
**String emitter**: `(buffer/push buf "...")` → source text
**Data-structure emitter**: `['keyword val1 val2]` → eval-able tuples
### Janet eval gotchas
- Bare tuples are function calls — always use `['tuple ...]` or `(tuple ...)`
- `eval` scope: symbols from `(use ...)` not available — embed function VALUES
- Janet `try`: `(try body ([err] handler))` — not `(catch sym handler)`
- Core `-` maps to `core-sub` (NOT `core--`)
### Loop compilation
`(loop* [x 0] body-with-recur)``(do (var name nil) (set name (fn [x] body)) (name 0))`
Recur rewrites to `(loop-name arg...)` via `:jolt/current-loop` binding.
### Quote: use `raw-form->janet` converter, never re-analyze
### Macro expansion: pass ctx to `analyze-form`, check `resolve-macro`, expand + re-analyze
## Special Form Checklist
To add a new special form to the evaluator AND compiler: