Generator * syntax

Rick Waldron waldron.rick at gmail.com
Mon Mar 3 16:03:45 PST 2014


On Mon, Mar 3, 2014 at 6:44 PM, joe <joeedh at gmail.com> wrote:

> Is the function* syntax for generators final?
>

Yes


> I'm curious what the justification for it is,
>

The yield keyword was previously only reserved in strict mode (ES5
7.6.1.2), which means it's perfectly valid JS to have: function f() { var
yield = 1; return yield; } in non-strict mode code. In order to allow
generator functions in both strict and non-strict code, where yield is a
keyword, a new syntactic form was needed, ie. the star (generator)
function. This avoids potentially breaking any existing code that is using
yield as an identifier.


> but mostly I just need to know if it's likely to change.
>

I'm confident that it will not change.

Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140303/df2aa91f/attachment.html>


More information about the es-discuss mailing list