core: cold tagged-type printing migrates to print-method defmethods

The first per-type migration print-method unlocked: uuid, regex, transient,
and channel rendering move from host pr-render branches to io-tier
defmethods (exact same output). The renderer's tagged fallthrough now
dispatches ANY remaining :jolt/* value through the print-method hook before
the raw pairs view — so every tagged type is user-overridable, atoms
included ((defmethod print-method :jolt/atom ...) fires nested), and future
per-type migrations are pure overlay additions.

Hot types (numbers, strings, symbols, collections) stay native, and inst/
namespace/var stay host for now — their formatters (rfc3339, display names)
live there anyway. A transient's :kind is read with jolt.host/ref-get: get
on a transient is the dispatched collection lookup (same trap as sorted
colls).

Before the hook is wired (init-time error messages) tagged values fall
through to the pairs view — bootstrap rendering only.
This commit is contained in:
Yogthos 2026-06-11 18:35:21 -04:00
parent 8efdd9956d
commit af3e49a89c
3 changed files with 47 additions and 6 deletions

View file

@ -95,3 +95,20 @@
"(let [w (StringWriter.)] (.write w \"a\") (.append w \\b) (.toString w))"]
["methods table inspectable" "true"
"(do (defrecord Pt [x y]) (defmethod print-method (quote user.Pt) [r w] r) (contains? (methods print-method) (quote user.Pt)))"])
# Cold tagged-type printing now lives in io-tier defmethods (the host
# renderer dispatches any remaining :jolt/* tagged value through the
# print-method hook). Outputs unchanged from the old host branches; any
# tagged type is now user-overridable, atoms included.
(defspec "io / cold tagged types via print-method"
["uuid" "\"#uuid \\\"b6883c0a-0342-4007-9966-bc2dfa6b109e\\\"\""
"(pr-str (parse-uuid \"b6883c0a-0342-4007-9966-bc2dfa6b109e\"))"]
["uuid nested" "\"[#uuid \\\"b6883c0a-0342-4007-9966-bc2dfa6b109e\\\"]\""
"(pr-str [(parse-uuid \"b6883c0a-0342-4007-9966-bc2dfa6b109e\")])"]
["regex" "\"#\\\"a+b\\\"\"" "(pr-str #\"a+b\")"]
["transient vector" "\"#<transient vector>\"" "(pr-str (transient [1]))"]
["transient map" "\"#<transient map>\"" "(pr-str (transient {:a 1}))"]
["atom override fires nested" "\"{:a #atom[7]}\""
"(do (defmethod print-method :jolt/atom [a w] (.write w (str \"#atom[\" (deref a) \"]\"))) (pr-str {:a (atom 7)}))"]
["uuid through str unchanged" "\"b6883c0a-0342-4007-9966-bc2dfa6b109e\""
"(str (parse-uuid \"b6883c0a-0342-4007-9966-bc2dfa6b109e\"))"])