yield syntax (diverging from: How would shallow generators compose with lambda?)

Brendan Eich brendan at mozilla.com
Sun May 17 11:48:37 PDT 2009


On May 17, 2009, at 11:00 AM, Brendan Eich wrote:

> Python differs from JS by having only assignment statements, not  
> assignment expressions, which simplifies the problem a bit, as the  
> grep output cited above shows.

Of course this makes trouble with automatic semicolon insertion,  
unless assignment statements are split from assignment expressions.  
D'oh!

js> function g() {z = yield a ? f : x++()}
typein:2: SyntaxError: missing ; before statement:
typein:2: function g() {z = yield a ? f : x++()}
typein:2: .................................^
js> function g() {(z = yield a ? f : x++)()}


> To confirm this, I patched WebKit's Bison grammar for JS to support  
> yield //a la// JS1.7. I didn't hook up the semantic actions, just  
> verified zero reduce-reduce conflicts. Patch attached below --  
> comments welcome (including from you WebKit lurkers :-).

Patching this is harder than I thought it would be. After hacking at  
the Bison grammar a bit, I concede your point about implementation  
difficulty!

Usability still favors the Python approach, at least for yield  
statements.

/be





More information about the es-discuss mailing list