3 ms·
Interesting ideas, and well-worded. You could achieve something similar in JavaScript with Promise.all() and await: await Promise.all([ asyncFunc1(),
by _bxg1 9y ago
Interesting ideas, and well-worded.
You could achieve something similar in JavaScript with Promise.all() and await:
await Promise.all([
asyncFunc1(),
asyncFunc2(),
asyncFunc3()
])
Of course, that's not language-level and the point seemed to focus more on eliminating traditional branching than just adding another way to do it.
- acjohnson55 9y agoI had a similar thought, initially, which I posted elsewhere in this submission: https://news.ycombinator.com/item?id=16924407 https://news.ycombinator.com/item?id=16924407
- Osiris 9y agoThat's exactly what I was thinking. Some of us are probably are using this type of control flow. For me a common scenario is something like const promises = files.map(readFileAsync); // "nursery" const fileContents = await Promise.all(promises); // "with" I generally agree with his premise that it sucks having to figure out if a function is concurrent or not; i.e., does it return a value or a Promise/Future. I'm not sure if his solution solves that particular issue though, unless it's handled automatically in his "nursery.start_soon" function.