Hi, an atom can be sufficient, but you need to drop to a lower level.
(defn !paws "Like swap! but returns the old value of the atom." [a f & args] (loop [] (let [old-value @a new-value (apply f old-value args)] (if (compare-and-set! a old-value new-value) old-value (recur))))) (peek (!paws atom-with-queue pop)) However, my suspicion is, that you don't clearly divide the state handling from the program logic. The peek should happen in the update function you pass to swap!. If this is not side-effect free, it means that you have to coordinate with other identities and resources. Then a ref or an agent might be indeed a better fit than the atom. Sincerely Meikel -- 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