jolt/.dirge/memory/MEMORY.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.6 KiB

Build: jpm test runs all tests; janet test/<file>.janet runs single. Source in src/jolt/, tests in test/. Entry: src/jolt/main.janet. Key files: compiler.janet (848L, 2-phase analyze→emit), evaluator.janet (interpreter with 21 special forms), core.janet (~130 Clojure core fns), types.janet (Var/Namespace/Context), reader.janet (parser), phm.janet (PersistentHashMap + LazySeq + PersistentHashSet), api.janet (public API + compile? dispatch), loader.janet (file loading). § Architecture: Two eval modes — compile (:compile? true) uses analyze-form→emit-expr→Janet eval; interpreter mode uses tree-walking evaluator.janet. Stateful forms (defmacro, ns, deftype, defmulti, defmethod, syntax-quote, set!, var, ., new) always fall back to interpreter. Macros expand at analyze time. Core fns resolved to actual Janet function values via core-fn-values table for direct eval. § Compile-mode eval path: compile-and-evalcompile-ast (emits Janet data structures with resolved fn values) → Janet eval. Source-to-source compile-form exists for debugging but NOT used by compile-and-eval. compile-and-eval interns def/defn results in Jolt namespace so interpreter can resolve them later. § REPL: main.janet initializes context and sets current ns to "user". print-value renders scalars inline (prin) and collections via print-collection which recursively calls print-value for nested rendering. Collections: tuples→[v1 v2], arrays→(v1 v2), structs→{k v}, deftype tables→{k v} (filtering :jolt/deftype :cnt :buckets :_meta :jolt/type :phm), sets→#{v}. Jolt symbol structs render as name or ns/name.