On a closer look:
((logger/log "map" @unique-offers)
(alter unique-offers assoc offer-value streams))
should probably be
(do (logger/log "map" @unique-offers)
(alter unique-offers assoc offer-value streams))
On Tue, Apr 26, 2011 at 9:55 PM, Jonathan Fischer Friberg <
[email protected]> 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 <[email protected]>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 [email protected]
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> [email protected]
>> 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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en