domenic at domenicdenicola.com (2013-11-22T17:55:20.071Z)
On Thu 14 Nov 2013 11:16:22 PM CET, Brendan Eich wrote:
> Claus Reinke wrote:
>> What I don't understand is why generator expressions are not used
>> as the only way to create generators, leaving 'function' alone.
>
> We have been over this before: to support flows that for-of loops
> cannot expression, specifically coroutine libraries such as
> http://taskjs.org/.
The suggested topics seem to be ignoring that use case (using the result
of the yield expression) and only considering the iterator case. The
suggestion:
() => (for (y of gen) y)
isn't going to work for generators that need the values of the yield
expression (like in task.js), right?
spawn(() *=> yield (yield this.user.getPendingFriendship(friendId)).setAccepted(true));
From what I've seen, async generators are so popular (at least in
node-land) that people are building entire frameworks[1] and library
ecosystems[2] based on them even though they're only available behind a
flag, in an unstable version of node. Even more, a dedicated transpiler
was written[3] to support transpiling *just* generators, with the async
use case in mind.
Right now from where I stand, its almost as if the other use case of
generators (as iterators) is completely unimportant.
So I really don't see how there isn't a strong enough case for generator
arrow functions.
[1]: https://github.com/koajs/
[2]: https://github.com/visionmedia/co/wiki
[3]: http://facebook.github.io/regenerator/
On Thu 14 Nov 2013 11:16:22 PM CET, Brendan Eich wrote: > Claus Reinke wrote: >> What I don't understand is why generator expressions are not used >> as the only way to create generators, leaving 'function' alone. > > We have been over this before: to support flows that for-of loops > cannot expression, specifically coroutine libraries such as > http://taskjs.org/. The suggested topics seem to be ignoring that use case (using the result of the yield expression) and only considering the iterator case. The suggestion: () => (for (y of gen) y) isn't going to work for generators that need the values of the yield expression (like in task.js), right? spawn(() *=> yield (yield this.user.getPendingFriendship(friendId)).setAccepted(true)); From what I've seen, async generators are so popular (at least in node-land) that people are building entire frameworks[1] and library ecosystems[2] based on them even though they're only available behind a flag, in an unstable version of node. Even more, a dedicated transpiler was written[3] to support transpiling *just* generators, with the async use case in mind. Right now from where I stand, its almost as if the other use case of generators (as iterators) is completely unimportant. So I really don't see how there isn't a strong enough case for generator arrow functions. [1]: https://github.com/koajs/ [2]: https://github.com/visionmedia/co/wiki [3]: http://facebook.github.io/regenerator/