core: print-method is a real multimethod (jolt-g1r); records print canonically

print-method/print-dup are now multimethods in the io tier with Clojure's
exact dispatch ((:type meta) keyword, else type — core.clj 3693). On jolt the
dispatch value for a record is its quoted full-name symbol, since class names
aren't values here.

Records used to pr-str as the raw janet table; the renderer's record branch
now prints Clojure's #ns.Type{:k v} syntax, and first consults a callback the
api wires up after the overlay loads — so a user defmethod on a record type
fires everywhere: top level, nested in collections, through pr/prn/pr-str.
Builtin overrides (a :number method) fire only on direct print-method calls;
pr keeps the native fast path (documented divergence).

java.io.Writer arrives as a shim beside the StringReader/StringBuilder ones:
a :jolt/writer tagged value with write/append/flush/toString, a StringWriter
ctor, and a sink variant the renderer callback uses.

Two latent host bugs fixed on the way: the interpreted syntax-quote splice
blew up on ~@nil (an interpreted macro's empty & rest binds nil — first tier
user of defmulti found it; d-realize now treats nil as the empty seq), and
(print-method x nil) now throws like the JVM instead of returning nil.

10 spec rows; bench dead even (sandwich run); greeter green on a fresh
binary.
This commit is contained in:
Yogthos 2026-06-11 18:10:11 -04:00
parent eff8cb99a5
commit 1e4a0a6d53
8 changed files with 131 additions and 9 deletions

View file

@ -1064,9 +1064,7 @@
(defn special-symbol? [s] (contains? special-syms s))
;; Printer hooks are inert until print-method is a real multimethod (jolt-g1r).
(defn print-method [x writer] nil)
(defn print-dup [x writer] nil)
;; print-method / print-dup are real multimethods in the io tier (50-io.clj).
;; JVM proxies don't exist on a Janet host: the read-only surface is inert,
;; the constructive surface throws (matching the prior seed stubs).