PersistentVector: 17-form .clj source, fully working.
- 32-way branching trie with tail optimization
- pv-conj, pv-nth, pv-assoc, pv-pop, vector?, vector constructor
- instance? check works on deftype tables
- .-field accessor syntax for deftype fields
api.janet: :mutable? compile flag for opt-out
- Default: persistent data structures loaded
- Pass {:mutable? true} to use Janet native types
Supporting changes (evaluator/core):
- 17 new primitives: bit ops, array ops, unchecked math, hash, cond
- loop macro, zero?, dec/inc, defn multi-arity
- instance? for deftype tables (get val :jolt/deftype)
- defrecord builds maps at expansion time
- .-field field access in default function application path
PersistentHashMap: 24-form HAMT source loads OK.
- BitmapIndexedNode/PersistentHashMap deftypes
- mask, bitpos, bit-count, index helpers
- phm-assoc/phm-get/phm-without/phm-contains? stubs
- bmn-assoc insert path structured, bitmap propagation wip
1.2 KiB
Janet try syntax: the error handler clause ([err] handler) must be on ONE line. Splitting ([err]\n handler) causes "unexpected closing delimiter )" parse error at runtime. This is a Janet parser limitation, not a Jolt issue. Fix: always write (try body ([err] handler-body)) on one line, or use (do ...) for multi-line handlers: (try body ([err] (do ...))).
§
Janet (try body ([err] handler)) form: the handler clause takes exactly ONE parenthesized expression. (try (do ... :ok) ([err] (printf \"%q\" err) :fail)) is valid — the handler returns :fail. But (try (do ... :ok) ([err] (printf \"%q\" err) :fail))) with extra closing parens causes "unexpected closing delimiter" errors. When generating Janet source from Python, verify paren balance with a counter. Also: (def result (try ... ([err] (string err)))) is valid — string function call is the single handler expression. Getting this wrong wastes many iterations.
§
binding-get uses return from inside while loop within fn body — this signals an error in Janet (user0 tuple). Must use (var result :jolt/not-found) + (when (in t name) (set result ...) (set t nil) (break)) pattern. Cannot use return for early exit from loops in Janet.