The Chez atom record gains watches (an alist of key->fn) and validator slots. swap!/reset! now validate the candidate value before storing and notify watches after, in the seed's order (core_refs.janet) — the watch fn is called (key ref old new). compare-and-set!/swap-vals!/reset-vals! route through reset!/swap! so they validate + notify too. add-watch/remove-watch/set-validator!/get-validator are native here and re-asserted in post-prelude.ss: the clojure.core overlay implements them via jolt.host/ref-put! on (get atom :watches), a Janet-table mutation a Chez atom record can't answer, so its def-var! would otherwise clobber these. set- validator! validates the current value immediately (Clojure throws if already invalid). Parity 2150 -> 2154, 0 new divergences. New test/chez/_atomwatch.janet 10/10. The (class x) native and the clojure.walk port were explored this increment but deferred: class alone makes the String-class-token corpus cases emit-and- run with a wrong value (the bare token doesn't resolve yet) — filed jolt-13zk to land the native together with token resolution; clojure.walk is blocked on list? + map-entry-as-vector (jolt-75sv).
40 lines
2.5 KiB
Scheme
40 lines
2.5 KiB
Scheme
;; post-prelude overrides (jolt-9ziu) — loaded AFTER the assembled clojure.core
|
|
;; prelude, so these win over the overlay's own def-var!.
|
|
;;
|
|
;; A few clojure.core predicates are implemented in the overlay by inspecting a
|
|
;; Janet-host tagged value's :jolt/type key (e.g. (get x :jolt/type)). That key
|
|
;; doesn't exist for Chez-native representations: a jolt char is a Scheme char,
|
|
;; an atom is a Chez record. The overlay's def-var! loads after rt.ss, so it
|
|
;; clobbers the correct native shims (predicates.ss / atoms.ss) with versions
|
|
;; that return false on every Chez value. Re-assert the native versions here.
|
|
;;
|
|
;; (Long-term these predicates want a host-neutral implementation that calls a
|
|
;; host primitive instead of reading :jolt/type; until then this is the Chez-host
|
|
;; override.)
|
|
(def-var! "clojure.core" "char?" jolt-char-pred?)
|
|
(def-var! "clojure.core" "atom?" jolt-atom?)
|
|
;; atom watches/validators: the overlay drives these via jolt.host/ref-put! on a
|
|
;; Janet table (get a :watches), which a Chez atom record is not — re-assert the
|
|
;; native versions (defined in atoms.ss), and swap!/reset! notify+validate there.
|
|
(def-var! "clojure.core" "add-watch" jolt-add-watch)
|
|
(def-var! "clojure.core" "remove-watch" jolt-remove-watch)
|
|
(def-var! "clojure.core" "set-validator!" jolt-set-validator!)
|
|
(def-var! "clojure.core" "get-validator" jolt-get-validator)
|
|
;; volatiles: a Chez volatile is a jvol record, but the overlay vreset!/vswap!/
|
|
;; volatile? drive it via jolt.host/ref-put!+get / :jolt/type (tagged-table only).
|
|
;; Override with the native versions (defined in natives-xform.ss).
|
|
(def-var! "clojure.core" "vreset!" jolt-vreset!)
|
|
(def-var! "clojure.core" "vswap!" jolt-vswap!)
|
|
(def-var! "clojure.core" "volatile?" jolt-volatile-pred?)
|
|
;; bound?: the overlay reads (get v :root) — nil on a Chez var-cell record, so it
|
|
;; would wrongly report every var unbound. Native version (defined in vars.ss).
|
|
(def-var! "clojure.core" "bound?" jolt-bound?)
|
|
;; uuid?/random-uuid/parse-uuid/tagged-literal? are overlay (read :jolt/type or
|
|
;; build tagged tables) — re-assert the native versions (defined in natives-misc.ss).
|
|
(def-var! "clojure.core" "uuid?" jolt-uuid-pred?)
|
|
(def-var! "clojure.core" "random-uuid" jolt-random-uuid)
|
|
(def-var! "clojure.core" "parse-uuid" jolt-parse-uuid)
|
|
(def-var! "clojure.core" "tagged-literal?" jolt-tagged-literal-pred?)
|
|
;; ns-name: the overlay reads (get ns :name) — nil on a jns namespace record.
|
|
;; Native version (defined in ns.ss) returns the namespace's name symbol.
|
|
(def-var! "clojure.core" "ns-name" jolt-ns-name)
|