yield syntax

Brendan Eich brendan at mozilla.com
Tue May 19 14:37:50 PDT 2009


On May 19, 2009, at 2:08 PM, David-Sarah Hopwood wrote:

> A more explicit alternative is to require some kind of decoration on  
> the
> function definition, e.g. (just a straw man):
>
>  function generator foo() { ... }

Or just (we discussed this briefly last summer in Oslo):

generator foo() { ... }

In JS1.7, we followed Python, which uses def, same as for defining a  
function, and distinguishes generators by presence of yield (which  
makes value returns illegal). It seems unwise to diverge from Python  
without more evidence of an actual usability problem. We have no such  
evidence from shipping JS1.7 and up in Firefox 2 and up.

/be



More information about the es-discuss mailing list