Replace str-render/instance-check set! chains with registries
jolt-str-render-one and instance-check were each extended by a chain of set!-wrapping closures spread across ~10 and ~5 host files, so the real behavior of either was scattered and load-order-dependent. Give each a registry the base file owns: converters.ss/records-interop.ss define the registry plus a register-* helper, and each extending file registers one arm instead of capturing %prev and set!-ing the global. str-render arms are type-disjoint; instance-check arms run newest-first (the old outermost-wins order) and may return 'pass to defer. The string-token -> symbol normalization the natives-array arm did for every inner arm moves to the dispatcher head; array tokens stay strings for that arm to decide. jolt-ogib.14. Runtime-only shims, no re-mint.
This commit is contained in:
parent
bc16513afd
commit
e434356590
14 changed files with 79 additions and 64 deletions
|
|
@ -487,16 +487,14 @@
|
|||
;; Pluggable instance? — a library registers (fn [class-name-string val] -> true
|
||||
;; | false | nil); nil means "not my class, fall through". First non-nil wins.
|
||||
(define user-instance-checks '())
|
||||
(define %hs-instance-check instance-check)
|
||||
(set! instance-check
|
||||
(register-instance-check-arm!
|
||||
(lambda (type-sym val)
|
||||
(let ((tname (symbol-t-name type-sym)))
|
||||
(let loop ((fs user-instance-checks))
|
||||
(if (null? fs)
|
||||
(%hs-instance-check type-sym val)
|
||||
'pass
|
||||
(let ((r ((car fs) tname val)))
|
||||
(if (jolt-nil? r) (loop (cdr fs)) (if (jolt-truthy? r) #t #f))))))))
|
||||
(def-var! "clojure.core" "instance-check" instance-check)
|
||||
(def-var! "clojure.core" "__register-instance-check!"
|
||||
(lambda (f) (set! user-instance-checks (append user-instance-checks (list f))) jolt-nil))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue