-
Notifications
You must be signed in to change notification settings - Fork 21
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
Coroutines should resolve with the generator return value #42
Comments
This is a great idea, thanks! |
References that behave the same: This would simplify my code a lot, currently I have to |
Do you think this is possible in a backwards compatible way? Or does this mean we need to do a 5.0.0 release? |
I think it's a breaking change because it changes the semantics. Any code that does if ($whatever) {
yield whatever();
return;
} will get I think it's worth it though. Nobody is forced to update after all, but those who do and new projects benefit from a lot less boilerplate, cleaner semantics and shared behavior with how other implementations work. #43 is also kind of a breaking change in case you relied on the error being thrown. |
Well I fully agree that this should happen. So lets make this a priority and cut a v5.0. Sucks a bit to have a major version just after the last, but worth it! |
agree, just do another major release. no worries. |
ETA for 5.0? |
Just released it! |
PHP 7 has
Generator::getReturn()
to get the return value of a generator. That means code like this is possible:But currently coroutines will always use the last
yield
value, which makes control flow like above weird.The text was updated successfully, but these errors were encountered: