On 11 July 2010 15:18, Jeffrey Schwab <j...@schwabcenter.com> wrote: > Which instance in time? Just once, up front, or could the deref happen anew > on each pass? Is there any way to know, in general, whether a deref is > guaranteed to happen only once, or might a macro like doseq move the > expression @a into the middle of a loop (or elide the deref altogether)?
I think these two snippets might be useful: user=> (def foo (atom #{1 2 3 4 5})) #'user/foo user=> (doseq [x (range 2) y @foo] (println x y) (swap! foo disj y)) 0 1 0 2 0 3 0 4 0 5 nil ...whereas... user=> (doseq [x (range 2) y #{1 2 3 4 5}] (println x y)) 0 1 0 2 0 3 0 4 0 5 1 1 1 2 1 3 1 4 1 5 nil On 11 July 2010 15:52, Stuart Halloway <stuart.hallo...@gmail.com> wrote: > Help me understand your confusion so I can improve the docstrings. I think it's not so much about the order of traversal of the seqs, but about the time when the seq expressions are evaluated. As displayed above, all seq expressions except the leftmost one are evaluated once *per iteration* (of their particular loop level), so their values might change between iterations. Sincerely, Michał -- 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