Re: Strange behavior with alts! and :default in core async

2014-08-15 Thread Eric Normand
> > 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 ev

Re: Strange behavior with alts! and :default in core async

2014-08-15 Thread dgrnbrg
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 be

Re: Strange behavior with alts! and :default in core async

2014-08-15 Thread Daniel Solano Gómez
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

Re: Strange behavior with alts! and :default in core async

2014-08-14 Thread dgrnbrg
You're all right--that was a cut & paste error. I meant that I see this behavior with alt!!, not alts! 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 sh

Re: Strange behavior with alts! and :default in core async

2014-08-14 Thread Ghadi Shayban
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 i

Re: Strange behavior with alts! and :default in core async

2014-08-14 Thread Eric Normand
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] (asy

Re: Strange behavior with alts! and :default in core async

2014-08-14 Thread Daniel Solano Gómez
Hello, I was just wondering if you are using the right function. Without actually trying to run any code, a couple of things pop into mind: 1. alts! can only be used in a go macro. 2. The invocation doesn't look right for alts!. Perhaps you want something like: (let [[val port] (async/alts!! [