So, if a list whose first element is a vector is provided after a get or a 
put in alt!, then that's treated as the binding form/code to be executed if 
that succeeds, but if a non-list is provided, then that is treated as a 
value to return if that action was taken (and that value is evaluated 
before any operation happens)?

On Friday, August 15, 2014 8:35:05 AM UTC-4, Daniel Solano Gómez wrote:
>
> On Thu Aug 14 19:04 2014, dgrnbrg wrote: 
> > You're all right--that was a cut & paste error. I meant that I see this 
> > behavior with alt!!, not alts! 
>
> With alt!!, it should probably be something like: 
>
> (let [result (alt!! [[inner-chan e]] ([v] (if v 
>                                             :put-a-value 
>                                             :channel-closed)) 
>                     :default :failed-to-put 
>                     :priority true)] 
>   (println result)) 
>
> I hope this helps. 
>
> Sincerely, 
>
> Daniel 
>
> > 
> > On Thursday, August 14, 2014 3:31:45 PM UTC-4, Ghadi Shayban wrote: 
> > > 
> > > What Daniel said.  The call is incorrect, its args are alt-shaped, but 
> it 
> > > calls alt*s*. 
> > > 
> > > alt is the macro that is shaped like cond. 
> > > alts is the function that takes a vector 
> > > 
> > > Both take splatted options at the end. 
> > > 
> > > Can never use single bang* except within go.* 
> > > 
> > > go => ! 
> > > thread => !! 
> > > 
> > > Unfortunately if the two are confused, the exception will happen... 
> > > probably elsewhere. 
> > > 
> > > On Thursday, August 14, 2014 2:46:22 PM UTC-4, Eric Normand wrote: 
> > >> 
> > >> Hi there, 
> > >> 
> > >> The :default option is for a *value* that should be returned if none 
> of 
> > >> the channels are available. The expression is evaluated *before* the 
> > >> async/alts! call happens (just like normal parameters). 
> > >> 
> > >> I think you are misunderstanding alts!. It should be used like this 
> > >> 
> > >> (let [[val ch] (async/alts! [[inner-chan e]] :default :default)] 
> > >>   (if (= :default val) 
> > >>     (println "inner-chan was not ready") 
> > >>     (if val 
> > >>       (println "did the put to inner-chan") 
> > >>       (println "inner-chan is closed")))) 
> > >> 
> > >> I hope that helps. Let me know if you have any more questions. 
> > >> 
> > >> Eric 
> > >> 
> > >> On Thursday, August 14, 2014 11:03:01 AM UTC-5, dgrnbrg wrote: 
> > >>> 
> > >>> When I use alts!, it seems that both the put and :default action run 
> > >>> every time. I've included the code sample below: 
> > >>> 
> > >>> (let [inner-chan (async/chan (async/buffer 1000)) 
> > >>>       mult (async/mult inner-chan) 
> > >>>   (async/thread 
> > >>>     (while true 
> > >>>       (let [e (.take linked-blocking-queue)] 
> > >>>         (async/alts! 
> > >>>           [[inner-chan e]] (println "did the put") 
> > >>>           :default (println "failed to put") 
> > >>>           :priority true))))) 
> > >>> 
> > >>> 
> > >>> Elsewhere in the code, I tap the mult before I start putting 
> elements 
> > >>> onto the linked-blocking-queue. For every element I put onto the 
> LBQ, I see 
> > >>> both messages: "did the put" and "failed to put". What is going on 
> here? 
> > >>> 
> > >> 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@googlegroups.com 
> <javascript:> 
> > Note that posts from new members are moderated - please be patient with 
> your first post. 
> > To unsubscribe from this group, send email to 
> > clojure+u...@googlegroups.com <javascript:> 
> > 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 unsubscribe from this group and stop receiving emails from it, send 
> an email to clojure+u...@googlegroups.com <javascript:>. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to