ocaml: phase 2 for/while loops (+5 tests, 194 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 52s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 52s
Parser: for i = lo to|downto hi do body done, while cond do body done. AST: (:for NAME LO HI :ascend|:descend BODY) and (:while COND BODY). Eval re-binds the loop var per iteration; both forms evaluate to unit.
This commit is contained in:
@@ -155,7 +155,8 @@ SX CEK evaluator (both JS and OCaml hosts)
|
||||
- [x] Unit `()` value; `ignore`.
|
||||
- [x] References: `ref`, `!`, `:=`.
|
||||
- [ ] Mutable record fields.
|
||||
- [ ] `for i = lo to hi do ... done` loop; `while cond do ... done`.
|
||||
- [x] `for i = lo to hi do ... done` loop; `while cond do ... done` (incl.
|
||||
`downto` direction).
|
||||
- [ ] `try`/`with` — maps to SX `guard`; `raise` via perform.
|
||||
- [ ] Tests in `lib/ocaml/tests/eval.sx` — 50+ tests, pure + imperative.
|
||||
|
||||
@@ -320,6 +321,9 @@ the "mother tongue" closure: OCaml → SX → OCaml. This means:
|
||||
|
||||
_Newest first._
|
||||
|
||||
- 2026-05-08 Phase 2 — `for`/`while` loops. `(:for NAME LO HI DIR BODY)`
|
||||
with `:ascend`/`:descend` direction (`to`/`downto`); `(:while COND BODY)`.
|
||||
Both eval to unit and re-bind the loop var per iteration. 194/194 (+5).
|
||||
- 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)`; `:=`
|
||||
|
||||
Reference in New Issue
Block a user