ocaml: phase 2 references ref/!/:= (+6 tests, 189 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 55s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 55s
ref is a builtin boxing its arg in a one-element list. Prefix ! parses to (:deref ...) and reads via (nth cell 0). := joins the binop precedence table at level 1 right-assoc and mutates via set-nth!. Closures share the underlying cell.
This commit is contained in:
@@ -153,7 +153,7 @@ SX CEK evaluator (both JS and OCaml hosts)
|
||||
- [x] `if`/`then`/`else`, `begin`/`end`, sequence `;`.
|
||||
- [x] Arithmetic, comparison, boolean ops, string `^`, `mod`.
|
||||
- [x] Unit `()` value; `ignore`.
|
||||
- [ ] References: `ref`, `!`, `:=`.
|
||||
- [x] References: `ref`, `!`, `:=`.
|
||||
- [ ] Mutable record fields.
|
||||
- [ ] `for i = lo to hi do ... done` loop; `while cond do ... done`.
|
||||
- [ ] `try`/`with` — maps to SX `guard`; `raise` via perform.
|
||||
@@ -320,6 +320,12 @@ the "mother tongue" closure: OCaml → SX → OCaml. This means:
|
||||
|
||||
_Newest first._
|
||||
|
||||
- 2026-05-08 Phase 2 — references (`ref`/`!`/`:=`). `ref` is a builtin
|
||||
that boxes its argument in a one-element list (the mutable cell);
|
||||
prefix `!` parses to `(:deref EXPR)` and reads `(nth cell 0)`; `:=`
|
||||
joins the precedence table at the lowest binop level (right-assoc) and
|
||||
short-circuits in eval to mutate via `set-nth!`. Closures capture refs
|
||||
by sharing the underlying list. 189/189 (+6).
|
||||
- 2026-05-08 Phase 3 — pattern matching evaluator + constructors (+18
|
||||
tests, 183 total). Constructor application: `(:app (:con NAME) arg)`
|
||||
builds a tagged list `(NAME …args)` with tuple args flattened (so
|
||||
|
||||
Reference in New Issue
Block a user