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
|
|
@ -62,16 +62,10 @@
|
|||
"}"))
|
||||
|
||||
;; ---- extend the collection dispatchers with a jrec arm ----------------------
|
||||
(define %r-jolt=2 jolt=2)
|
||||
(set! jolt=2 (lambda (a b)
|
||||
(cond ((jrec? a) (and (jrec? b) (jrec=? a b)))
|
||||
((jrec? b) #f)
|
||||
(else (%r-jolt=2 a b)))))
|
||||
(register-eq-arm! (lambda (a b) (or (jrec? a) (jrec? b)))
|
||||
(lambda (a b) (and (jrec? a) (jrec? b) (jrec=? a b))))
|
||||
(register-hash-arm! jrec? jrec-hash)
|
||||
(define %r-jolt-get jolt-get)
|
||||
(set! jolt-get (case-lambda
|
||||
((coll k) (if (jrec? coll) (jrec-lookup coll k jolt-nil) (%r-jolt-get coll k)))
|
||||
((coll k d) (if (jrec? coll) (jrec-lookup coll k d) (%r-jolt-get coll k d)))))
|
||||
(register-get-arm! jrec? (lambda (coll k d) (jrec-lookup coll k d)))
|
||||
(define %r-jolt-count jolt-count)
|
||||
(set! jolt-count (lambda (coll) (if (jrec? coll) (length (jrec-pairs coll)) (%r-jolt-count coll))))
|
||||
(define %r-jolt-contains? jolt-contains?)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue