-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed as not planned
Closed as not planned
Copy link
Labels
area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).Dart language related items (some items might be better tracked at github.com/dart-lang/language).closed-staleClosed as the issue or PR is assumed staleClosed as the issue or PR is assumed stalecore-ntype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Description
- Dart SDK Version (
dart --version)
Dart VM version: 2.0.0-dev.32.0 (Thu Mar 1 18:39:53 2018 +0100) on "macos_x64"
Problem
In dart language, generator's yield language construct is a statement and cannot gain any value.
Although in Python and JavaScript (ES 2015), yield is a expression and can get value like:
Iterable func() sync* {
var x = yield 33; // this is error with current Dart
}
Where the return value of yield is expected to be given from iterator side, for example:
func().moveNext("hello"); // this is an error with current Dart. moveNext cannot take parameter.
To get value from yield is extremely valuable when use generator to implement coroutine,
moreover actually it is necessarily.
I hope we can use "yield expression" in future Dart release.
References:
-
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield
rv Returns the optional value passed to the generator's next() method to resume its execution. -
https://stackoverflow.com/questions/12637768/python-3-send-method-of-generators
cah4a, uehaj, paulreimer, cowboyd, taras and 8 more
Metadata
Metadata
Assignees
Labels
area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).Dart language related items (some items might be better tracked at github.com/dart-lang/language).closed-staleClosed as the issue or PR is assumed staleClosed as the issue or PR is assumed stalecore-ntype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug