Re: Changes in chrome JS code due to ES6 global lexical scope

2015-09-18 Thread Shu-yu Guo
Good catch and thanks for the correction! The take-home from the example is that: due to the global lexical scope, a TDZ error could arise later due to newly introduced bindings. On Thu, Sep 17, 2015 at 7:34 PM, Boris Zbarsky wrote: > On 9/17/15 8:26 PM, Shu-yu Guo wrote: > >>

Re: Changes in chrome JS code due to ES6 global lexical scope

2015-09-18 Thread Neil
Shu-yu Guo wrote: Good catch and thanks for the correction! The take-home from the example is that: due to the global lexical scope, a TDZ error could arise later due to newly introduced bindings. So for that I guess the code would have to look like this? var x; function f() { dump(x); }

Re: Changes in chrome JS code due to ES6 global lexical scope

2015-09-18 Thread Gervase Markham
On 17/09/15 19:59, Shu-yu Guo wrote: > ​Because ​until now, our global 'let' semantics have been identical to > those of 'var', I have already landed a patch that mass replaces global > 'let' with 'var' as part of bug 1202902. I think someone should make you a "var is the new let" t-shirt...

Re: Changes in chrome JS code due to ES6 global lexical scope

2015-09-18 Thread Tom Schuster
I think that would fail as well, because the let would be shadowing the global x, which isn't allowed. On Sep 18, 2015 2:25 PM, "Neil" wrote: > Shu-yu Guo wrote: > > Good catch and thanks for the correction! The take-home from the example is >> that: due to the global

Changes in chrome JS code due to ES6 global lexical scope

2015-09-17 Thread Shu-yu Guo
Hello all, ​We are in the process of implementing the global lexical scope per ES6. This changes the semantics of global level 'let' and 'const' bindings from our non-standard semantics to standard semantics. Currently, global 'let' and 'const' bindings ​introduce properties onto the global

Re: Changes in chrome JS code due to ES6 global lexical scope

2015-09-17 Thread Boris Zbarsky
On 9/17/15 8:26 PM, Shu-yu Guo wrote: ​The first call to f() does not throw. It actually does, because the bareword lookup for "x" fails. You get "ReferenceError: x is not defined". If you replaced "x" with "window.x" or "self.x" or "this.x" or something I think you'd get the behavior you

Re: Changes in chrome JS code due to ES6 global lexical scope

2015-09-17 Thread Neil
Shu-yu Guo wrote: 4. The global lexical scope is extensible. This means dynamic scope (lol!): function f() { dump(x); } f(); // prints undefined​ ​ ​let x = 42; f(); // prints 42 Would you mind clarifying what this is supposed to demonstrate? It looks to me that this is demonstrating TDZ

Re: Changes in chrome JS code due to ES6 global lexical scope

2015-09-17 Thread Shu-yu Guo
On Thu, Sep 17, 2015 at 5:18 PM, Neil wrote: > Shu-yu Guo wrote: > > 4. The global lexical scope is extensible. This means dynamic scope (lol!): >> >> >> function f() { dump(x); } >> f(); // prints undefined​ >> ​ >> >> >> ​let x = 42; >> f(); // prints 42 >> >> >> Would

Re: Changes in chrome JS code due to ES6 global lexical scope

2015-09-17 Thread Shu-yu Guo
(Isn't that bananas, by the way?) On Thu, Sep 17, 2015 at 5:26 PM, Shu-yu Guo wrote: > On Thu, Sep 17, 2015 at 5:18 PM, Neil wrote: > >> Shu-yu Guo wrote: >> >> 4. The global lexical scope is extensible. This means dynamic scope >>> (lol!): >>> >>> >>>