`this` inside modules
Domenic Denicola
domenic at domenicdenicola.com
Sun Jun 8 21:25:32 PDT 2014
https://gist.github.com/caridy/eefb9b104874465d4e1c#2-whats-the-execution-context-for-a-module seems to indicate `this` will become some sort of module meta object with a variety of abilities: `this.name`, `this.address`, `this.import`, `this.get`, and `this.module`.
This seems like another unfortunate addition to the WTFJS canon, as it continues to add more confusing meanings for `this` to the mix.
IMO it would be much better to leave `this` as `undefined`, just as it is in strict mode scripts, and thus be able to tell a consistent story that in ES6, `this` is about methods. The current proposal would instead create a world where `this` is about methods most of the time, but is a magic ambient variable in some cases (sloppy scripts, modules). This kind of confusion is evident even in the title of that section: it asks "what is the execution context for a module," but it is actually talking about `this`, which has nothing to do with [execution contexts][1].
If a magically in-scope binding is necessary to access module meta capabilities, giving it a name like `module` or `System.currentModule` would be much better.
[1]: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-execution-contexts
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140609/98c8ff10/attachment.html>
More information about the es-discuss
mailing list