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

@ -122,8 +122,8 @@
["proxy-super throws" :throws "(proxy-super count [1])"]
["re-groups throws" :throws "(re-groups (re-matcher #\"a\" \"b\"))"]
["re-matcher builds" "false" "(nil? (re-matcher #\"a\" \"abc\"))"]
["print-dup" "nil" "(print-dup 1 nil)"]
["print-method" "nil" "(print-method 1 nil)"]
["print-dup nil writer throws" :throws "(print-dup 1 nil)"]
["print-method nil writer throws" :throws "(print-method 1 nil)"]
["uri? string" "false" "(uri? \"http://x\")"]
["uri? nil" "false" "(uri? nil)"]
["definterface defines" "true" "(var? (definterface IFoo (foo [x])))"]