refactor: registry pattern for jolt-get + jolt=2 (jolt-lmot)
jolt-get (4 sites: host-table/natives-misc/inst-time/records) and jolt=2 (6 sites: records/vars/inst-time/natives-misc/bigdec/host-table) move off the set!-rebind chains to register-get-arm! / register-eq-arm!. get's case-lambda becomes a stable 2/3-arg entry over a 3-arg dispatch; the equality arm pred is (a b) since either arg may carry the type, and the host-table sorted arm normalizes-then-re-dispatches. Behaviour-preserving (runtime .ss): var/inst/bigdec/record/uuid equality, record!=map, sorted-map=plain-map, and all the get cases verified; make test green, 0 new corpus divergences. Four of six dispatchers done; the printer (pr-str/pr-readable) remains.
This commit is contained in:
parent
d168d1195b
commit
acf3e1ffd3
8 changed files with 63 additions and 65 deletions
|
|
@ -61,11 +61,8 @@
|
|||
(def-var! "clojure.core" "bigdec" jolt-bigdec)
|
||||
|
||||
;; equality: a bigdec equals only another bigdec, by value (matching (= 3M 3) = false).
|
||||
(define %bd-jolt=2 jolt=2)
|
||||
(set! jolt=2 (lambda (a b)
|
||||
(cond ((and (jbigdec? a) (jbigdec? b)) (jbigdec=? a b))
|
||||
((or (jbigdec? a) (jbigdec? b)) #f)
|
||||
(else (%bd-jolt=2 a b)))))
|
||||
(register-eq-arm! (lambda (a b) (or (jbigdec? a) (jbigdec? b)))
|
||||
(lambda (a b) (and (jbigdec? a) (jbigdec? b) (jbigdec=? a b))))
|
||||
|
||||
;; str drops the M; pr/pr-str keep it.
|
||||
(register-str-render! jbigdec? jbigdec->string)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue