spec: vector primitives — bounds-checked ref/set!, vector-copy start/end slice

vector-ref and vector-set! now raise Eval_error on out-of-bounds index instead of
an OCaml array exception. vector-copy accepts optional start and end parameters for
slicing (R7RS §6.8). spec/primitives.sx doc updated to reflect slice params.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-25 19:27:54 +00:00
parent 3759575b29
commit d1a00562a4
3 changed files with 30 additions and 7 deletions

View File

@@ -50,8 +50,10 @@ Primitives to add:
- `vector-copy` `v` `[start]` `[end]` → fresh copy of slice
Steps:
- [ ] OCaml: add `SxVector of value array` to `hosts/ocaml/sx_types.ml`; implement all
- [x] OCaml: add `SxVector of value array` to `hosts/ocaml/sx_types.ml`; implement all
primitives in `hosts/ocaml/sx_primitives.ml` (or equivalent); wire into evaluator.
Note: Vector type + most prims were already present; added bounds-checked vector-ref/set!
and optional start/end to vector-copy. 10/10 vector tests pass (r7rs suite).
- [ ] Spec: add vector entries to `spec/primitives.sx` with type signatures and descriptions.
- [ ] JS bootstrapper: implement vectors in `hosts/javascript/platform.js` (or equivalent);
ensure `sx-browser.js` rebuild picks them up.
@@ -194,4 +196,5 @@ Brief each language's loop agent (or do inline) after rebasing their branch onto
_Newest first._
- 2026-04-25: Phase 1 OCaml step done — bounds-checked vector-ref/set!, vector-copy now accepts optional start/end, spec/primitives.sx doc updated. 10/10 r7rs vector tests pass, 4747 total (394 pre-existing hs-upstream fails unchanged).
- 2026-04-25: Phase 0 complete — stopped CL/APL/Ruby/Tcl loops (all 4 idle at shell); confirmed E38 (tokenizer :end/:line) and E39 (WebWorker stub) both have implementation commits.