core: Phase 4 — move vreset!/vswap! to the overlay (reusing ref-put!)

vreset! sets the volatile's :val slot through the jolt.host/ref-put! primitive
added in the last batch; vswap! is pure over vreset! + get. The volatile!
constructor stays native (it builds the mutable box). Covered by the existing
state spec.
This commit is contained in:
Yogthos 2026-06-07 21:27:20 -04:00
parent 4d5aa8c903
commit a9403e26b0
2 changed files with 9 additions and 8 deletions

View file

@ -286,3 +286,10 @@
(jolt.host/ref-put! (get a :watches) key nil) a)
(defn set-validator! [a f]
(jolt.host/ref-put! a :validator f) nil)
;; Volatiles. The constructor (volatile!) stays native — it builds the mutable box —
;; but vreset! sets the box's slot through ref-put! and vswap! is pure over it + get.
(defn vreset! [vol newval]
(jolt.host/ref-put! vol :val newval) newval)
(defn vswap! [vol f & args]
(vreset! vol (apply f (get vol :val) args)))