New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add deferred/alt #102
Add deferred/alt #102
Conversation
|
@danielcompton could you please explain why randomization is useful in this case? I can't find any rationalization for why Core.Async does that. |
Not sure if I can put it into words well, but the intuition is to avoid accidentally ordering things which shouldn't be ordered, or depending on the order that ports are declared in an alt. Say you were testing with dummy data and you filled all your channels up, then ran the alt. If it took the first every time then you may miss subtle concurrency bugs that would occur in production. |
This makes sense. I was thinking along the same lines. I see two options then:
I have no strong feelings either way. |
[& vals] | ||
(let [d (deferred)] | ||
(clojure.core/loop [s vals] | ||
(when-let [x (first s)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this pick a random ordering?
Hi, I'm sorry for not responding to this sooner. I think I'd prefer the randomized approach, and |
Randomized now. I used the random-array-filling technique from core.async (except the storing |
Sorry for the delay in merging this, I'll be cutting a release soon. |
This adds a
deferred/alt
combinator. Naming mirrors thecore.async/alt..
functions. Alsoalt
has the same length aszip
, its dual. I find it aesthetically pleasing :)I find it occasionally useful. Would you consider pulling into Manifold?