tcl: Phase 3 OCaml primitives — file I/O + clock; refresh prolog scoreboard
file-read/write/append/exists?/glob + clock-seconds/milliseconds/format registered in sx_primitives.ml; unix dep added to dune. Unlocks Tcl open/read/puts-to-file, glob, clock seconds/format commands. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -34,7 +34,7 @@ Everything here is pure Tcl implementation work.
|
||||
| [x] | Float in `expr` — detect `.` in number tokens, route through float ops instead of `parse-int` | half day | `expr {3.14 * 2}`, `expr {sqrt(2.0)}`, float comparisons |
|
||||
| [x] | `regexp pattern str` and `regsub pattern str repl` wrapping existing SX primitives | few hours | pattern matching, text processing |
|
||||
| [x] | `apply {args body} ?arg…?` — anonymous proc call | 1 hour | higher-order functions, `lmap` idiom |
|
||||
| [ ] | `array get/set/names/size/exists/unset` commands | half day | array variables (tokenizer already parses `$arr(key)`) |
|
||||
| [x] | `array get/set/names/size/exists/unset` commands | half day | array variables (tokenizer already parses `$arr(key)`) |
|
||||
|
||||
**Total: ~2 days. Zero SX changes.**
|
||||
|
||||
@@ -42,6 +42,11 @@ Everything here is pure Tcl implementation work.
|
||||
|
||||
## Phase 2 — `lib/fiber.sx` (pure SX library, no OCaml)
|
||||
|
||||
| Status | Work |
|
||||
|---|---|
|
||||
| [x] | Create `lib/fiber.sx` — `make-fiber` / `fiber-resume` / `fiber-done?` |
|
||||
| [x] | Rewrite `tcl-cmd-coroutine` to use `make-fiber` (true suspension) |
|
||||
|
||||
`call/cc` is multi-shot and `set!` on closed-over vars both work. Fibers are
|
||||
implementable as a pure SX library using symmetric continuation swapping:
|
||||
|
||||
@@ -87,14 +92,14 @@ Tcl coroutines then rewrite using `make-fiber` for true suspension.
|
||||
Each is ~10–20 lines of OCaml. All are useful across the whole platform, not
|
||||
just Tcl.
|
||||
|
||||
| Primitive | OCaml effort | Unlocks |
|
||||
|---|---|---|
|
||||
| `(file-read path)` → string | tiny | Tcl `open`/`read`, SX scripts reading files |
|
||||
| `(file-write path str)` → nil | tiny | Tcl `open`/`puts` to files |
|
||||
| `(file-exists? path)` → bool | tiny | Tcl `file exists` |
|
||||
| `(file-glob pattern)` → list | small | Tcl `glob` |
|
||||
| `(clock-seconds)` → int | tiny | Tcl `clock seconds` |
|
||||
| `(clock-format n fmt)` → string | small (wraps `strftime`) | Tcl `clock format` |
|
||||
| Status | Primitive | OCaml effort | Unlocks |
|
||||
|---|---|---|---|
|
||||
| [x] | `(file-read path)` → string | tiny | Tcl `open`/`read`, SX scripts reading files |
|
||||
| [x] | `(file-write path str)` → nil | tiny | Tcl `open`/`puts` to files |
|
||||
| [x] | `(file-exists? path)` → bool | tiny | Tcl `file exists` |
|
||||
| [x] | `(file-glob pattern)` → list | small | Tcl `glob` |
|
||||
| [x] | `(clock-seconds)` → int | tiny | Tcl `clock seconds` |
|
||||
| [x] | `(clock-format n fmt)` → string | small (wraps `strftime`) | Tcl `clock format` |
|
||||
|
||||
**Total: 1 day. One focused afternoon of OCaml.**
|
||||
|
||||
@@ -141,6 +146,10 @@ becomes a lasting SX contribution used by every future hosted language.
|
||||
|
||||
_Newest first._
|
||||
|
||||
- 2026-05-06: Phase 3 OCaml primitives — file-read/write/append/exists?/glob + clock-seconds/milliseconds/format in sx_primitives.ml + unix dep; tcl-cmd-clock/file wired up; 337/337 green
|
||||
- 2026-05-06: Phase 2 coroutine rewrite — `tcl-cmd-coroutine` now creates a `make-fiber`; `tcl-cmd-yield` calls `:coro-yield-fn` (threaded through interp); true suspension; 337/337 green
|
||||
- 2026-05-06: Phase 2 fiber.sx — `make-fiber`/`fiber-resume`/`fiber-done?` using call/cc + set!; bidirectional value passing; generator and echo tests pass
|
||||
- 2026-05-06: Phase 1 array — `tcl-cmd-array` get/set/names/size/exists/unset; frame-local key scanning with prefix `arrname(`; 337/337 tests green
|
||||
- 2026-05-06: Phase 1 apply — `tcl-cmd-apply` wraps `tcl-call-proc`, parses `{args body}` funcList, full frame isolation; 329/329 tests green
|
||||
- 2026-05-06: Phase 1 regexp/regsub — `tcl-cmd-regexp`/`tcl-cmd-regsub` wrapping `make-regexp`/`regexp-match`/`regexp-match-all`/`regexp-replace`/`regexp-replace-all`; -nocase/-all/-inline/-all flags; matchVar + subgroup capture; 329/329 tests green
|
||||
- 2026-05-06: Phase 1 float expr — `tcl-num-float?`, `tcl-parse-num`, float-aware `tcl-apply-binop`/`tcl-apply-func`/unary-minus/`**`; `sqrt`/`floor`/`ceil`/`round`/`sin`/`cos`/`tan`/`pow`/`exp`/`log` all float-native; 329/329 tests green
|
||||
|
||||
Reference in New Issue
Block a user