apl: :Trap exception machinery — Phase 7 complete (+5 tests, 450/450)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m8s

apl-throw raises a tagged ("apl-error" code msg) error.
apl-trap-matches? checks if codes list contains the error's code
(0 = catch-all, à la Dyalog).

Eval-stmt :trap clause wraps try-block with R7RS guard;
on match, runs catch-block; on mismatch, re-raises.
Bonus :throw AST node for testing.

test.sh + conformance.sh now load lib/r7rs.sx (for guard) and
include eval-ops + pipeline suites in scoreboard.

All Phase 7 unchecked items are now ticked.
Final scoreboard: 450/450 across 10 suites.
This commit is contained in:
2026-05-07 14:53:22 +00:00
parent 67ff2a3ae8
commit 0dd2fa3058
8 changed files with 74 additions and 11 deletions

View File

@@ -130,7 +130,7 @@ and tightens loose ends.
- [x] **Idiom corpus expansion** — extend `idioms.sx` from 34 to 60+ once
end-to-end works (we can express idioms as APL strings, not as runtime
calls). Source-string-based idioms validate the whole stack.
- [ ] **`:Trap` / `:EndTrap`** — minimal exception machinery: `:Trap n`
- [x] **`:Trap` / `:EndTrap`** — minimal exception machinery: `:Trap n`
catches errors with code `n`, body runs in `apl-tradfn-eval-block`,
on error switches to the trap branch. Define `apl-throw` and a small
set of error codes; use `try`/`catch` from the host.
@@ -149,6 +149,7 @@ data; format for string templating.
_Newest first._
- 2026-05-07: Phase 7 step 6 — :Trap exception machinery via R7RS guard; apl-throw raises tagged error, apl-trap-matches? checks codes (0=catch-all), :trap clause in apl-tradfn-eval-stmt wraps try-block with guard; :throw AST for testing; **Phase 7 complete, all unchecked plan items done**; +5 tests; 450/450
- 2026-05-07: Phase 7 step 5 — idiom corpus 34→64 (+30 source-string idioms via apl-run); also fixed tokenizer + parser to recognize ≢ and ≡ glyphs (were silently skipped); 445/445
- 2026-05-07: Phase 7 step 4 — bracket indexing `A[I]` desugared to `(:dyad ⌷ I A)` via maybe-bracket helper, wired into :name + :lparen branches of collect-segments-loop; multi-axis (A[I;J]) deferred (semicolon split); +7 tests; 415/415
- 2026-05-07: Phase 7 step 3 — :quad-name end-to-end; tokenizer already produced :name "⎕FMT"; parser is-fn-tok? extended via apl-quad-fn-names; eval-ast :name dispatches ⎕IO/⎕ML/⎕FR/⎕TS to apl-quad-*; apl-monadic-fn handles ⎕FMT; ⎕← deferred (tokenizer splits ⎕←); +8 tests; 408/408