Skip to content

Should JS iterators implement Dart Iterable? #28320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vsmenon opened this issue Jan 10, 2017 · 1 comment
Open

Should JS iterators implement Dart Iterable? #28320

vsmenon opened this issue Jan 10, 2017 · 1 comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. type-enhancement A request for a change that isn't a bug web-js-interop Issues that impact all js interop

Comments

@vsmenon
Copy link
Member

vsmenon commented Jan 10, 2017

From @jmesserly on June 25, 2015 23:26

This seems like it would be useful in general. The downside is that something could have [Symbol.iterator]() but already define some of the same method names as Dart's Iterable, so we'd have to decide which one wins (at least, for dynamic dispatch).

Without this, we won't have very good interop with JS generators, so IMO it's worth it. It would also simplify sync* (#221), so Dart generators just get Iterable "for free". Otherwise we'll have to wrap the ES6 generator.

Exposing explicit conversion APIs would be the other way to go here.

See also #245, a similar issue with Future/Promise.

Copied from original issue: dart-archive/dev_compiler#247

@vsmenon vsmenon added web-dev-compiler type-enhancement A request for a change that isn't a bug labels Jan 10, 2017
@vsmenon
Copy link
Member Author

vsmenon commented Jan 10, 2017

From @jmesserly on July 17, 2015 20:0

one complication can be seen in

// TODO(sigurdm): Check up on the spec here.

Unlike ES6 generators, Dart sync* functions seem to capture parameters differently. Even though the generator function is only called once, each iterator gets a fresh copy of the parameter. It's not clear to me that this is actually specified one way or the other, but for now I'm going to try and match the other implementations.

edit: it's still useful to make interop better, so this bug is worth fixing. but I'm not sure sync* function bodies can actually be function* in JS, unless the parameters aren't mutated (which is probably common, and we already look for that in other cases and use it to generate better code).

@jmesserly jmesserly added web-js-interop Issues that impact all js interop and removed web-dev-compiler labels Apr 20, 2018
@vsmenon vsmenon added the area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. label Jul 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. type-enhancement A request for a change that isn't a bug web-js-interop Issues that impact all js interop
Projects
None yet
Development

No branches or pull requests

3 participants