John Barton (2014-06-09T16:58:03.000Z)
domenic at domenicdenicola.com (2014-06-12T22:27:45.605Z)
On Mon, Jun 9, 2014 at 9:40 AM, Caridy Patino <caridy at gmail.com> wrote: > another issue with `this` being `global` (as it is today by the specs) is > the way top level modules will be defined in a page, assuming we will have > `type="module"` for scripts (which is probably were we want to be), what > will be the difference between: > > ```html > <script type="module"> > this.foo = 1; > var bar = 2; > import main from "main"; > </script> > ``` > > and > > ```html > <script> > this.foo = 1; > var bar = 2; > System.import("main"); > </script> > ``` In the 'module', 'bar' is local and 'main' is imported before the module is evaluated. In 'script' bar is global and the 'main' is imported at the end of the script. The fate of 'this.foo' hangs in the balance until TC39 speaks. > it seems to me that the current definition, where `this` is `global`, will > be an issue when it comes to avoid global variable definition. Ideally, for > modules, `this.foo` and `bar` will be contained, to have a clear > differentiation with the regular `script` tags. My point: if 'this' is not global in modules, then ES6 must have an alternative way to name the global object.