jolt/.dirge/skills/jolt-gotchas/SKILL.md
Yogthos 053ed4f790 Phase 8: Protocol System — defprotocol, extend-type, extend-protocol, satisfies?
- types.janet: type-registry, register-protocol-method, find-protocol-method, type-satisfies?
- core.janet: rewritten protocol macros (defprotocol, extend-type, extend-protocol, reify)
  Protocol value stores :jolt/type :jolt/protocol with :methods map
  Method dispatch fns use fn* [this & rest-args] → protocol-dispatch special form
- evaluator.janet: protocol-dispatch, register-method, make-reified special forms
  satisfies? special form with type registry lookup
  special-symbol? entries for all 3 protocol ops + satisfies?
- 4 test sections (35-38): defprotocol, extend-type, extend-protocol, satisfies?
  extend-type: basic dispatch works (42 constant), .-field accessor needs further debug
  satisfies?: fully functional with type registry
- 315 ok, 2 fail (pre-existing, unchanged)
2026-06-03 00:18:41 -04:00

1.5 KiB

name description
jolt-gotchas Common pitfalls and workarounds discovered during Jolt implementation

jolt-gotchas

Recurring pitfalls and their fixes discovered across all implementation phases.

PHM/Set Metadata Key Leakage

PHM and set internal keys (:jolt/deftype, :cnt, :buckets, :_meta, :jolt/type, :phm) leak into pairs/keys iteration. Must filter in merge, merge-with, keys, vals, and print-collection.

(when (and (not= k :jolt/deftype) (not= k :cnt) 
           (not= k :buckets) (not= k :_meta)
           (not= k :jolt/type) (not= k :phm)) ...)

Keywords with # Are Invalid Janet Literals

:#inst, :#uuid cause parse errors. Use dynamic table construction:

(let [dr @{}] (put dr (keyword "#inst") fn) dr)

Janet break Only Works in Loops

Does NOT work inside let. Use (var found nil) + (set found val) (break) pattern.

Bare Tuples in eval Are Function Calls

(eval [1 2 3]) calls 1 as function. Use ['tuple 1 2 3] in data-structure emitter.

Janet case for Multi-Arity

Janet lacks Clojure-style multi-arity defn. Use (defn f [& args] (case (length args) 1 ... 2 ...)).

core-renames + core-fn-values Must Stay in Sync

Both tables must be updated together when adding core fns. Missing entries = silent nil returns. "-" is core-sub NOT core--.

set! Field Mutation Reader Quirk

(set! (.-x obj) val) parses as array with .-x symbol head — not as standalone .-x symbol. Check for this case before the (. obj -field) shorthand.