Closed
Description
Asynchronous iterators are increasingly well-supported. Should CoffeeScript 2 provide first-class support for them?
This would require supporting an additional for
syntax corresponding to for await … of
in JavaScript. Perhaps CoffeeScript can add for await … from
?
The problem here is analogous to the problem that inspired for … from
—namely, you cannot use for
loops naturally with async iterators otherwise.
In addition, it would require allowing functions that contain both await
and yield
and generating async function*
declarations, aka async generator functions.
Activity
GeoffreyBooth commentedon Feb 2, 2018
This is normally where I squash the party and say that we need to wait for Stage 4, blah blah, but actually . . . async iterators reached Stage 4 last month! So yes, definitely, let’s add this.
You are correct, the CoffeeScript version would need to use
from
, as that’s our keyword that equates toof
. You’d think that with all the copying of CoffeeScript that the ECMA committee did, they could’ve avoided usingof
for something different than what we use it for. But we can’t change things now.So yes, if you or someone else would like to implement
for await … from
, and remove the current errors that the compiler throws when trying to combineawait
and iterators, that would be welcomed.