Replaced bit-trie HAMT with simple array-based implementation.
Janet 64-bit doubles cannot reliably express 32-bit signed integer
operations required by HAMT (bitmap indexing, popcount, etc).
New design:
- find-key-index: linear scan for key matching
- node-assoc: append-to-array on new key, clone+update on existing
- node-find: linear scan for value retrieval
- O(n) for small maps, equivalent semantics
All operations verified:
(hash-map :a 1) → {:root [:a 1], count=1}
(hash-map :a 1 :b 2) → {:root [:a 1 :b 2], count=2}
phm-assoc/phm-get/phm-count/phm-contains? all correct
Value replacement preserves count correctly
1.1 KiB
1.1 KiB
jolt-dev
Jolt development workflow — build, test, special form patterns, Janet gotchas
Jolt Development
Build & Test
cd /Users/yogthos/src/jolt
jpm build # produces build/jolt
jpm test # runs all tests
janet test/foo.janet # run a single test file from project root
Special Form Checklist
To add a new special form to the evaluator:
- Add the name to
special-symbol?insrc/jolt/evaluator.janet - Add a match arm in
eval-list(the match onname) - Add tests in
test/evaluator-test.janet
The match arm receives ctx, bindings, and form (the full list). Use (in form 1) for first arg, etc.
Non-symbol heads (keywords, etc.): eval-list first checks (and (struct? first-form) (= :symbol (...))) before extracting name. If not a symbol, falls through to default function application.
Current special forms (22):
quote, syntax-quote, unquote, unquote-splicing, do, if, def, defmacro, fn*, let*, loop*, recur, throw, try, set!, var, locking, instance?, defmulti, defmethod, deftype, new, .