(core.async/go nil) behavior?

2013-12-14 Thread Stephen Cagle
core.async discourages you from placing nil in a channel, as nil is only taken when the channel has been closed. However, if I create a go block with a body that evaluates to nil, core.async will return a channel that contains nil. This is a nil as a take! value, not a nil to indicate the

Re: (core.async/go nil) behavior?

2013-12-14 Thread Brandon Bloom
Sounds like a bug to me. A nil value in return position of a go block should probably close the channel. On Saturday, December 14, 2013 2:18:07 PM UTC-5, Stephen Cagle wrote: core.async discourages you from placing nil in a channel, as nil is only taken when the channel has been closed.

Re: (core.async/go nil) behavior?

2013-12-14 Thread Timothy Baldridge
How do you know where the nil is coming from? Channels never accept nil, so any nil you get from a take is due to the channel bing closed. And yes, returning nil from a go causes the go's channel to close without a put. Timothy On Sat, Dec 14, 2013 at 4:35 PM, Brandon Bloom

Re: (core.async/go nil) behavior?

2013-12-14 Thread Stephen Cagle
Huh, that is pretty clever. You're right, I just assumed I was seeing the body result. That is a pretty clever way to fix the issue. nil just closes the returned channel, causing future takes on it to return nil. Neat. On Saturday, December 14, 2013 11:18:07 AM UTC-8, Stephen Cagle wrote: