Consider this contrived piece of code:

(def aval (atom {:dumped false :contents "hello world"}))

(defn update!
  [item]
  (when-not (:dumped item)
    (spit "a.out" (:contents item) :append true)
    (assoc item :dumped true)))

How should I correctly call update! ? Each of following two calls have 
drawbacks.

(swap! aval update!) ;; update! can be called more than once

(let [new-val (update! aval)]
  ;; aval can be changed in between from other thread
  (reset! aval new-val))

Best,
Jozef

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to