refactor: registry pattern for jolt-pr-str/pr-readable + remaining arms (jolt-lmot)
The printer's two entry points (jolt-pr-str in rt.ss, jolt-pr-readable in printing.ss) get register-pr-str-arm! / register-pr-readable-arm!, plus register-pr-arm! for the types whose str and readable forms match (bigdec/inst/uuid/tagged/record/ns/var). The normalize arms (sorted, lazy-seq, queue) and the uri readable arm register per-printer. Also folds in the hash (dyn-binding var-cell), class (io uri/uuid/file), and get (transients) arms missed earlier. natives-array's get stays a case-lambda wrapper on purpose: its 2-arg path errors on an out-of-bounds index while the 3-arg path returns the default, an arity distinction the (coll k d) registry collapses — left as-is to preserve behaviour. Completes jolt-lmot: all six dispatchers (hash/class/get/=/pr-str/pr-readable) off the set!-rebind chains. make test green, 0 new corpus divergences; pr-str/str of inst, uuid, bigdec, sorted-map, record-with-lazyseq, queue all verified.
This commit is contained in:
parent
acf3e1ffd3
commit
9a21325972
14 changed files with 48 additions and 64 deletions
|
|
@ -53,10 +53,7 @@
|
|||
;; str of a uuid -> the bare 36-char string; pr-str -> #uuid "…".
|
||||
(register-str-render! juuid? juuid-s)
|
||||
(define (juuid-pr u) (string-append "#uuid \"" (juuid-s u) "\""))
|
||||
(define %m-pr-str jolt-pr-str)
|
||||
(set! jolt-pr-str (lambda (x) (if (juuid? x) (juuid-pr x) (%m-pr-str x))))
|
||||
(define %m-pr-readable jolt-pr-readable)
|
||||
(set! jolt-pr-readable (lambda (x) (if (juuid? x) (juuid-pr x) (%m-pr-readable x))))
|
||||
(register-pr-arm! juuid? juuid-pr)
|
||||
;; two uuids are = iff same string.
|
||||
(register-eq-arm! (lambda (a b) (or (juuid? a) (juuid? b)))
|
||||
(lambda (a b) (and (juuid? a) (juuid? b) (string=? (juuid-s a) (juuid-s b)))))
|
||||
|
|
@ -83,10 +80,7 @@
|
|||
((jolt=2 k kw-tl-form) (jtagged-form coll))
|
||||
(else d))))
|
||||
(define (jtagged-pr t) (string-append "#" (jolt-pr-str (jtagged-tag t)) " " (jolt-pr-readable (jtagged-form t))))
|
||||
(define %m2-pr-str jolt-pr-str)
|
||||
(set! jolt-pr-str (lambda (x) (if (jtagged? x) (jtagged-pr x) (%m2-pr-str x))))
|
||||
(define %m2-pr-readable jolt-pr-readable)
|
||||
(set! jolt-pr-readable (lambda (x) (if (jtagged? x) (jtagged-pr x) (%m2-pr-readable x))))
|
||||
(register-pr-arm! jtagged? jtagged-pr)
|
||||
(def-var! "clojure.core" "tagged-literal" jolt-tagged-literal)
|
||||
;; tagged-literal? is OVERLAY (reads :jolt/type) — asserted in post-prelude.ss.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue