Proposal: Generator returning a value should throw SyntaxError

Adam Ahmed aahmed at atlassian.com
Thu Sep 26 19:18:27 PDT 2013


Thanks, I see. The usage is for TaskResult sorts of things where the
scheduling is done via calls to `yield`, and the output of the function is
done via `return`. Fair enough. It still seems like a huge footgun for the
other cases which I'd expect are far more common than cooperative
scheduling, but I can respect that decision.

Cheers!


On 27 September 2013 12:00, Brendan Eich <brendan at mozilla.com> wrote:

> Sorry, premature send!
>
>> Brendan Eich <mailto:brendan at mozilla.com>
>> September 26, 2013 6:57 PM
>>
>> We deliberated long and hard, after going through a design state without
>> return expr;, on this. We agree with
>>
>> http://www.python.org/dev/**peps/pep-0380/<http://www.python.org/dev/peps/pep-0380/>
>>
>
> We want return expr; -- not for the 'for-of' special forms, which clients
> use knowingly to consume in-band values, not the OOB return value -- but
> for the case of generators used as tasks (see ), where the scheduler can
> make good use of the return value:
>
> https://github.com/mozilla/**task.js <https://github.com/mozilla/task.js>
>
> /be
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130927/44f306ed/attachment.html>


More information about the es-discuss mailing list