plans: tick Phase 6 — namespace, list ops, dict additions, scan/format, exec [WIP]
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -291,6 +291,31 @@ inside a proc body (the typical async accept pattern).
|
||||
|
||||
---
|
||||
|
||||
## Phase 6 — Command surface fill-out ✓
|
||||
|
||||
After Phases 1–5 the architecture and IO model are complete. What remains
|
||||
is filling in the command surface that real Tcl scripts depend on.
|
||||
|
||||
| Status | Work | Effort | Why it matters |
|
||||
|---|---|---|---|
|
||||
| [x] | **Phase 6a — namespace polish (`::var`)** | small | `set ::var` from inside a proc now resolves to the global (root) frame. Tokenizer also updated so `$::var` substitution works. Surfaced during socket -async test design. |
|
||||
| [x] | **Phase 6b — list ops audit** | few hours | Added `lassign`, `lrepeat`, `lset`, `lmap`. (`lsearch`, `lreplace`, `lreverse` were already present.) |
|
||||
| [x] | **Phase 6c — `dict` command additions** | small | `dict create/get/set/unset/exists/keys/values/for/update/merge/incr/append` were already implemented. Added `dict lappend`, `dict remove`, `dict filter -key`. |
|
||||
| [x] | **Phase 6d — `scan` and `format`** | few hours | Added `printf-spec` and `scan-spec` SX primitives wrapping OCaml `Printf`/`Scanf` via `Scanf.format_from_string`. Tcl `format` rewrote to dispatch via `printf-spec`; `scan` is a real walker that fills variables. Supports `%d %i %u %x %X %o %c %s %f %e %E %g %G %%` with width/precision/flags. |
|
||||
| [x] | **Phase 6e — `exec`** | few hours | `exec-process` SX primitive wraps `Unix.create_process` + `Unix.waitpid` and captures stdout. Tcl `exec cmd arg...` returns trimmed stdout; non-zero exit raises an error including stderr. Pipelines/redirection (`\|`, `>`, `<`) are not yet parsed. |
|
||||
|
||||
**Bonus perf:** `tcl-global-ref?` (called on every var-get/set) was using
|
||||
`(substring name 0 2)` — re-allocating a 2-char string per call. Switched
|
||||
to `(char-at name 0)` + `(char-at name 1)` which short-circuits on
|
||||
non-`:` names. ~6× speedup on tight loops (`factorial 10`: 16s → 2.5s).
|
||||
|
||||
`tcl-call-proc` was discarding `:fileevents`, `:timers`, and `:procs`
|
||||
updates made inside Tcl proc bodies — only `:commands` was forwarded.
|
||||
Now forwards the full set. Surfaced when socket-async made
|
||||
fileevent-from-inside-proc the canonical pattern.
|
||||
|
||||
---
|
||||
|
||||
## Suggested order
|
||||
|
||||
1. **Phase 1** — immediate Tcl wins, zero risk, proves the approach
|
||||
@@ -307,6 +332,11 @@ becomes a lasting SX contribution used by every future hosted language.
|
||||
|
||||
_Newest first._
|
||||
|
||||
- 2026-05-07: Phase 6e exec — exec-process SX primitive (Unix.create_process+waitpid, captures stdout, errors on non-zero exit with stderr) + Tcl `exec cmd arg...`; +3 idiom tests
|
||||
- 2026-05-07: Phase 6d scan/format — printf-spec + scan-spec SX primitives wrapping OCaml Printf/Scanf via Scanf.format_from_string; Tcl format rewritten to dispatch via printf-spec; scan is real walker; supports d/i/u/x/X/o/c/s/f/e/E/g/G/% with width/precision/flags; +7 idiom tests
|
||||
- 2026-05-07: Phase 6c dict additions — dict lappend / remove / filter -key (rest of dict was already implemented); +3 idiom tests
|
||||
- 2026-05-07: Phase 6b list ops — lassign / lrepeat / lset / lmap added (lsearch/lreplace/lreverse were already present); +6 idiom tests
|
||||
- 2026-05-07: Phase 6a namespace `::` prefix — tcl-global-ref?/strip-global helpers; tcl-var-get/set route `::name` to root frame; tokenizer parse-var-sub also accepts `::` start so `$::var` substitution works; tcl-call-proc forwards :fileevents/:timers/:procs; char-at fast-path optimization (~6× speedup on tight loops); +4 idiom tests
|
||||
- 2026-05-07: Phase 5f socket -async — socket-connect-async (Unix.set_nonblock+connect/EINPROGRESS) + channel-async-error (getsockopt_error); Tcl `socket -async host port` returns immediately; `fconfigure $sock -error` queries async error; +3 idiom tests; 376/376 green
|
||||
- 2026-05-07: Phase 5e clock options + scan — clock-format extended with tz arg (utc/local) + more specifiers; new clock-scan primitive with manual timegm; Tcl clock format/scan support -format/-timezone/-gmt; +5 idiom tests; 373/373 green
|
||||
- 2026-05-07: Phase 5d file ops — file-size/mtime/isfile?/isdir?/readable?/writable?/stat/delete/mkdir/copy/rename SX primitives; Tcl file isfile/isdir/readable/writable/size/mtime/atime/type/mkdir/copy/rename/delete now real; +10 idiom tests; 368/368 green
|
||||
|
||||
Reference in New Issue
Block a user