Phase 13: Protocol Completion — reify dispatch, #() reader, IFn protocol

- reader.janet: rewrite read-anon-fn to handle % arg references
  % → gensym, %1/%2 → sorted gensyms, replaces all matching % refs
- evaluator.janet: IFn protocol support in default invocation arm
  Before erroring "Cannot call X as a function", checks for:
  1) type-registry IFn/-invoke method (extend-type protocols)
  2) :jolt/protocol-methods :-invoke (reified objects)
- test/phase13-test.janet: 4 test sections (28-31)
  28: reify dispatch — protocol methods on reified objects
  29: #() anon-fn — % and %1/%2 arg handling
  30: extend-type — protocol method dispatch for deftypes
  31: clojure.walk loading — keywordize-keys loads correctly
- All pass: 316 ok, 1 fail (pre-existing, unchanged)
This commit is contained in:
Yogthos 2026-06-03 13:19:56 -04:00
parent 5d7f392666
commit df1e836cda
7 changed files with 130 additions and 44 deletions

View file

@ -2,44 +2,22 @@
"jolt-gotchas": {
"created_by": "agent",
"use_count": 4,
"view_count": 240,
"view_count": 256,
"patch_count": 4,
"last_used_at": "2026-06-03T16:12:06.850822+00:00",
"last_viewed_at": "2026-06-03T16:51:46.822185+00:00",
"last_viewed_at": "2026-06-03T17:19:39.580796+00:00",
"last_patched_at": "2026-06-03T16:12:23.546648+00:00",
"created_at": "2026-06-03T03:50:41.474730+00:00",
"state": "active",
"pinned": false
},
"jpm-build": {
"created_by": "agent",
"use_count": 0,
"view_count": 252,
"patch_count": 0,
"last_viewed_at": "2026-06-03T16:51:46.833321+00:00",
"created_at": "2026-06-01T20:56:39.144222+00:00",
"state": "active",
"pinned": false
},
"jolt-compiler": {
"created_by": "agent",
"use_count": 12,
"view_count": 253,
"patch_count": 10,
"last_used_at": "2026-06-03T16:35:41.304993+00:00",
"last_viewed_at": "2026-06-03T16:51:46.810154+00:00",
"last_patched_at": "2026-06-03T16:13:25.725903+00:00",
"created_at": "2026-06-02T17:54:38.690279+00:00",
"state": "active",
"pinned": false
},
"jolt-bootstrap": {
"created_by": "agent",
"use_count": 9,
"view_count": 261,
"view_count": 277,
"patch_count": 10,
"last_used_at": "2026-06-02T18:45:23.336653+00:00",
"last_viewed_at": "2026-06-03T16:51:46.804059+00:00",
"last_viewed_at": "2026-06-03T17:19:39.564734+00:00",
"last_patched_at": "2026-06-02T03:44:45.935676+00:00",
"created_at": "2026-06-01T21:49:51.101718+00:00",
"state": "active",
@ -48,22 +26,44 @@
"jolt-persistent-structures": {
"created_by": "agent",
"use_count": 3,
"view_count": 240,
"view_count": 256,
"patch_count": 0,
"last_used_at": "2026-06-03T16:13:31.440242+00:00",
"last_viewed_at": "2026-06-03T16:51:46.828298+00:00",
"last_viewed_at": "2026-06-03T17:19:39.585778+00:00",
"created_at": "2026-06-03T03:35:04.130959+00:00",
"state": "active",
"pinned": false
},
"jpm-build": {
"created_by": "agent",
"use_count": 0,
"view_count": 268,
"patch_count": 0,
"last_viewed_at": "2026-06-03T17:19:39.591024+00:00",
"created_at": "2026-06-01T20:56:39.144222+00:00",
"state": "active",
"pinned": false
},
"jolt-compiler": {
"created_by": "agent",
"use_count": 12,
"view_count": 269,
"patch_count": 10,
"last_used_at": "2026-06-03T16:35:41.304993+00:00",
"last_viewed_at": "2026-06-03T17:19:39.570381+00:00",
"last_patched_at": "2026-06-03T16:13:25.725903+00:00",
"created_at": "2026-06-02T17:54:38.690279+00:00",
"state": "active",
"pinned": false
},
"jolt-dev": {
"created_by": "agent",
"use_count": 39,
"view_count": 291,
"patch_count": 47,
"last_used_at": "2026-06-03T16:35:41.292589+00:00",
"last_viewed_at": "2026-06-03T16:51:46.816038+00:00",
"last_patched_at": "2026-06-03T16:36:06.347582+00:00",
"use_count": 40,
"view_count": 308,
"patch_count": 48,
"last_used_at": "2026-06-03T17:02:10.695363+00:00",
"last_viewed_at": "2026-06-03T17:19:39.575770+00:00",
"last_patched_at": "2026-06-03T17:02:24.207040+00:00",
"created_at": "2026-06-01T21:26:06.614465+00:00",
"state": "active",
"pinned": false

View file

@ -36,6 +36,12 @@ janet test/phase10-test.janet # standard library
printf "(range 10)\n[1 2 3]\n{:a 1}\n" | janet src/jolt/main.janet
```
## Test File Creation — Heredoc Workaround
The `write` tool's syntax checker rejects `.janet` files with complex string escaping (e.g., `\"` inside Janet strings). **Workaround:** Use `bash` with `cat > file << 'EOF' ... EOF` heredocs for any test file containing Clojure source strings.
**Paren-counting boundary:** Large single-file test suites (>6 sections) often hit a mysterious paren-counting parse error ("unexpected end of source") at section boundaries, even when parens are balanced. **Workaround:** Split into multiple files (e.g., `cljs-port-1a.janet`, `cljs-port-1b.janet`).
## Loading .clj Files
`.clj` files are loaded via `eval-form` in the interpreter: