I have given only part of function. I have condition like this : (cond (and (empty? @unique-offers) (empty? @all-offers))
I change in dosync both unique-offers and all-offers. If I use your suggestion (empty? @unique-offers) (dosync ... alter ...) Can I get in situation where unique-offers is old value but all-offers is new value? Thanks On Tue, Apr 26, 2011 at 9:55 PM, Jonathan Fischer Friberg < odysso...@gmail.com> wrote: > I don't know. > However, given the situation I think > > (cond > (empty? @unique-offers) (dosync ... alter ...) > :else (logger/log "error")) > > is better, since the change is more isolated. > > On Tue, Apr 26, 2011 at 9:45 PM, Zlatko Josic <zlatko.jo...@gmail.com>wrote: > >> Hi, >> >> I use cond in dosync but it doesn't work. Here is a function code: >> >> >> (defn process-request >> [offer args] >> (logger/log "process called") >> (let [offer-value (Double/parseDouble (:offer offer)) >> out-queue (:out-queue args) >> unique-offers (:unique-offers args) >> all-offers (:all-offers args) >> streams (:streams offer)] >> (dosync >> (cond >> (empty? @unique-offers) >> ((logger/log "map" @unique-offers) >> (alter unique-offers assoc offer-value streams)) >> :else (logger/log "error"))))) >> >> unique-offer is ref for map which is empty so condition (empty? >> @unique-offers) is true. >> Statement (alter unique-offers assoc offer-value streams) never changes >> unique-offers map. >> If I remove cond from function it works fine (The function has only dosyn >> and alter). >> >> What am I doing wrong? >> >> Thanks >> >> -- >> 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 > > > -- > 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 -- 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