Phase 5/6 complete: Transients, meta/with-meta, instance?

T5.5 Transients (transient/persistent!/conj!/assoc!)
  - Mutable builder for batch vector/map operations
  - Use with let bindings for proper ordering

T6.10 meta/with-meta — metadata on any CljVal via ref object field
T6.11 instance? — type predicate (instance? :integer 42)

Also marked T9.1 Atoms as done (already implemented earlier)

86 tests pass, all examples work.
Phases 0-6 now complete. Phase 7: 2/4 tasks done.
This commit is contained in:
2026-05-08 19:48:35 +03:00
parent 66d91cd086
commit b67962dbba
4 changed files with 112 additions and 13 deletions
+8 -8
View File
@@ -31,7 +31,7 @@
| T5.2 | HAMT Vector — integration | ✅ | 🔴 | `lib/cljnim_runtime.nim`, `src/emitter.nim` | `ckVector` uses HAMT. All 51 `vecData` usages migrated. |
| T5.3 | HAMT Map | ✅ | 🔴 | New: `lib/cljnim_pmap.nim`, `lib/cljnim_runtime.nim` | Persistent Hash Map with HAMT. `assoc`, `dissoc`, `get` in O(log₃₂ n). 16 tests. |
| T5.4 | Persistent Set | ✅ | 🟡 | `lib/cljnim_runtime.nim` | Set backed by Persistent Hash Map. `conj`, `disj`, `contains?`, `get`, `count`. Reader emits `(set [items])`. |
| T5.5 | Transients | | 🟡 | `lib/cljnim_runtime.nim` | `transient`, `persistent!`, `conj!`, `assoc!` for batch mutations. |
| T5.5 | Transients | | 🟡 | `lib/cljnim_runtime.nim` | `transient`, `persistent!`, `conj!`, `assoc!` for batch mutations. Use with `let`. |
**Why HAMT matters**: Current Vector is a Nim `seq` — every `conj` copies the entire array (O(n)). Real Clojure uses Hash Array Mapped Trie for O(log₃₂ n) updates with structural sharing.
@@ -52,8 +52,8 @@
| T6.7 | `repeat`, `cycle`, `iterate` | ✅ | 🟡 | `lib/cljnim_runtime.nim` | `(repeat n x)`, `(cycle n coll)`, `(iterate n f x)`. Eager. |
| T6.8 | `take`, `drop` — seq slicing | ✅ | 🟢 | `lib/cljnim_runtime.nim` | `(take 5 (range 100))`, `(drop 5 [1 2 3 4 5])`. |
| T6.9 | `partition`, `interleave` | ✅ | 🟢 | `lib/cljnim_runtime.nim` | `(partition 2 [1 2 3 4])`, `(interleave [1 2] [3 4])`. |
| T6.10 | `meta`, `with-meta`, `vary-meta` | | 🟡 | `lib/cljnim_runtime.nim`, `src/types.nim` | Metadata support on vars, functions, collections. |
| T6.11 | `type`, `instance?` | | 🟢 | `lib/cljnim_runtime.nim` | `(type 42)``:int`. `(instance? :int 42)` → true. |
| T6.10 | `meta`, `with-meta`, `vary-meta` | | 🟡 | `lib/cljnim_runtime.nim`, `src/emitter.nim` | Metadata support on vars, functions, collections. |
| T6.11 | `type`, `instance?` | | 🟢 | `lib/cljnim_runtime.nim` | `(type 42)``:integer`. `(instance? :integer 42)` → true. |
---
@@ -82,7 +82,7 @@
| ID | Task | Status | Complexity | Files | Acceptance Criteria |
|---|---|---|---|---|---|
| T9.1 | Atoms (CAS) | | 🟡 | `lib/cljnim_runtime.nim` | `(def a (atom 0))`, `(swap! a inc)`, `(reset! a 42)`, `(deref a)`. |
| T9.1 | Atoms (CAS) | | 🟡 | `lib/cljnim_runtime.nim` | `(def a (atom 0))`, `(swap! a inc)`, `(reset! a 42)`, `(deref a)`. Already implemented. |
| T9.2 | Agents | ⬜ | 🟡 | `lib/cljnim_runtime.nim` | `(def ag (agent 0))`, `(send ag inc)`. Async execution. |
| T9.3 | core.async channels | ⬜ | 🔴 | New: `lib/cljnim_async.nim` | `(chan)`, `(>! ch val)`, `(<! ch)`, `(go ...)`. Simplified version. |
@@ -93,11 +93,11 @@
These tasks are **small, well-defined, and high impact**:
1. **T6.1 `str`** ✅ — Done. `cljStrConcat` in runtime, `str` mapping in emitter.
2. **T6.3 `slurp`** — Alias of existing `cljFileRead`. 1 line of work.
3. **T6.4 `spit`** — Alias of existing `cljFileWrite`. 1 line of work.
2. **T6.3 `slurp`** ✅ — Done. ``(slurp "file.txt")`` works.
3. **T6.4 `spit`** ✅ — Done. ``(spit "file.txt" "content")`` works.
4. **T6.8 `take`, `drop`** ✅ — Done. `cljTake`, `cljDrop` in runtime, emitter mappings.
5. **T6.11 `type`, `instance?`** ✅ — Done. `cljType` in runtime, `type` mapping in emitter.
6. **T4.6 Tool-call format** — Wrap REPL input parser to accept `{"tool":...}`.
5. **T6.11 `type`, `instance?`** ✅ — Done. `cljType`, `cljInstanceP` in runtime.
6. **T4.6 Tool-call format** — Wrap REPL input parser to accept `{"tool":...}`.
---