Generator issue: exceptions while initializing arguments
Domenic Denicola
domenic at domenicdenicola.com
Tue Sep 11 01:53:34 PDT 2012
On Sep 11, 2012, at 4:39, "Brendan Eich" <brendan at mozilla.com> wrote:
> Brendan Eich wrote:
>> Dmitry Soshnikov wrote:
>>> var FOO = 42;
>>> function bar(x, y = FOO + z) { var z = 10; } // Error .. ?
>>
>> Translating to JS as it is:
>>
>> var FOO = 42;
>> function bar(x, y) {
>> if (y === void 0) y = FOO + z;
>> var z = 10;
>> }
>
> Another benefit of the simple semantics: existing JITs can optimize easily, no new semantics to special-case. This is not a dominant concern but it is a selling point from my experience dealing with (and playing one on TV ;-)) implementors.
>
> /be
And, if one replaced all `var`s in the above example with `let`s, one would get the desired error, right? To me the most important use cases to consider are those in an "idiomatic ES6" let-is-the-new-var world.
More information about the es-discuss
mailing list