I have two maps in refs and want to assoc them to each other in one transaction.
My function looks like this:
(defn assoc-two
[one two]
(let [newone (assoc @one :two two)
newtwo (assoc @two :one one)]
(ref-set one newone)
(ref-set two newtwo)))
Now i am calling assoc-two
like this:
(dosync (assoc-two (ref {}) (ref {})))
Im getting and StackOverflowError at this point.
I also tried this:
(defn alter-two
[one two]
(alter one assoc :two two)
(alter two assoc :one one))
Is there away to do this in way that one
has an entry referencing two
and vice versa and still being in one transaction?