ocaml: phase 2 let..and.. mutual recursion (+3 tests, 251 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 51s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 51s
Parser collects multiple bindings via 'and', emitting (:def-rec-mut BINDINGS) for let-rec chains and (:def-mut BINDINGS) for non-rec. Single bindings keep the existing (:def …) / (:def-rec …) shapes. Eval (def-rec-mut): allocate placeholder cell per binding, build joint env where each name forwards through its cell, then evaluate each rhs against the joint env and fill the cells. Even/odd mutual-rec works.
This commit is contained in:
@@ -145,8 +145,11 @@ SX CEK evaluator (both JS and OCaml hosts)
|
||||
### Phase 2 — Core evaluator (untyped)
|
||||
|
||||
- [x] `ocaml-eval` entry: walks OCaml AST, produces SX values.
|
||||
- [~] `let`/`let rec`/`let ... in` (single-binding done; mutually recursive
|
||||
`and` deferred).
|
||||
- [x] `let`/`let rec`/`let ... in`. Mutually recursive `let rec f = … and
|
||||
g = …` works at top level via `(:def-rec-mut BINDINGS)`; placeholders
|
||||
are bound first, rhs evaluated in the joint env, cells filled in.
|
||||
`let x = … and y = …` (non-rec) emits `(:def-mut BINDINGS)` —
|
||||
sequential bindings against the parent env.
|
||||
- [x] Lambda + application (curried by default — auto-curry multi-param defs).
|
||||
- [x] `fun`/`function` (single-arg lambda with immediate match on arg).
|
||||
- [x] `if`/`then`/`else`, `begin`/`end`, sequence `;`.
|
||||
@@ -327,6 +330,11 @@ the "mother tongue" closure: OCaml → SX → OCaml. This means:
|
||||
|
||||
_Newest first._
|
||||
|
||||
- 2026-05-08 Phase 2 — `let ... and ...` mutual recursion at top level.
|
||||
Parser collects all bindings into a list, emitting `(:def-rec-mut)` or
|
||||
`(:def-mut)` when there are 2+. Eval allocates a placeholder cell per
|
||||
recursive binding, builds an env with all of them visible, then fills
|
||||
the cells. Even/odd mutual-recursion test passes. 251/251 (+3).
|
||||
- 2026-05-08 Phase 6 — `lib/ocaml/runtime.sx` minimal stdlib slice
|
||||
written entirely in OCaml syntax: List (length, rev, rev_append, map,
|
||||
filter, fold_left/right, append, iter, mem, for_all, exists, hd, tl,
|
||||
|
||||
Reference in New Issue
Block a user