Skip to content

Proposal: Support Asynchronous Iterators #4875

Closed
@dyoder

Description

@dyoder

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

GeoffreyBooth commented on Feb 2, 2018

@GeoffreyBooth
Collaborator

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 to of. You’d think that with all the copying of CoffeeScript that the ECMA committee did, they could’ve avoided using of 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 combine await and iterators, that would be welcomed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Proposal: Support Asynchronous Iterators · Issue #4875 · jashkenas/coffeescript