Re: core.async: throwing an exception into the channel

2013-08-01 Thread Alice
throw! is an explicit operation, and there's no special channel states involved. It's passing an exception like other data that just automatically throws it when taken. So it won't hurt anybody. You can use it when you need it, you can ignore it if you don't need it. Yet, it makes using async

Re: core.async: throwing an exception into the channel

2013-08-01 Thread John D. Hume
I think I'd rather see separate functions or macros for consuming from a channel with the maybe throw behavior rather than having the standard consume form(s) come with that feature (or threat, depending on whether you want it). At that point you're back to the earlier advice to wrap core.async to

Re: core.async: throwing an exception into the channel

2013-08-01 Thread Sean Corfield
My first thought was: Since channels can have arbitrary values, how would you distinguish your magical thrown exception value from an exception value put into a channel for normal delivery? And no matter how you annotate that, it'll still just be a regular value. So the only way you could have

core.async: throwing an exception into the channel

2013-07-31 Thread Alice
It would be nice to have a function throw! that puts an exception into the channel and throws it when taken, so that I can write (let [c (chan)] (go (throw! c (Exception.))) (go (try (prn (! c)) (catch Throwable t (prn exception) instead of (let [c (chan)]

Re: core.async: throwing an exception into the channel

2013-07-31 Thread Timothy Baldridge
The position of core.async is to not specify how exceptions should be done (instead leaving it up to the user). So if that method works well for you, write some macros and use it! Other methods may be the use of supervisor channels. In this model, go blocks that die would enqueue the exception