Chez Phase 2 (inc S): atom watches + validators (jolt-mn9o)
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).
This commit is contained in:
parent
1f96351acb
commit
b7864100cb
4 changed files with 135 additions and 12 deletions
|
|
@ -13,6 +13,13 @@
|
|||
;; 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).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue