-
Notifications
You must be signed in to change notification settings - Fork 1
Description
I had some questions that I asked Raynos today about yielding arrays - I didn't understand why the spec has a section about that.
The answer was that:
Yielding arrays is done to enable a parallel primitive without dependending on a third party library - this would allow any arbitrary generator on npm to use parallel execution without having to ask himself "is the AGen compliant runner going to support my parallel thing" ?
Thats a great goal, but if the spec doesn't specify the minimum supported types of asynchrony. This means that the answer to the question
"is the AGen compliant runner going to support my parallel thing" ?
is always: I have no idea - what kind of asynchrony does it use?
For all we know, the AGen compliant runner only works with Reactive Extensions primitives, and your published generator relies on yielding promises. And thats the reason why I'm not getting the benefit of specifying behavior when yielding arrays... The primitives may already be incompatible, so why specify the behavior of arrays?
Another point is that once you change the type of asynchrony, the method to achieve parallelism may also change. As an example, genny doesn't even have an asynchrony type - it yields emptiness most of the time. And it achieves parallelism by running operations without yielding, then yielding the resumer function the same number of times. Same thing applies to promises too - arrays are completely unnecessary to achieve parallelism there. You can just start the operations in parallel and get promises, then loop through all the promises to yield them.
The only remaining situation where yielding arrays is really beneficial are thunks...
So my question kind of is, what goal does this spec aim to achieve? Am I missing something obvious here?