`this` inside modules

Axel Rauschmayer axel at rauschma.de
Sun Jun 8 23:27:35 PDT 2014

I completely agree and was, in fact, going to write my own email on this topic, because I strongly believe we should leave `this` alone in modules.

Instead, let’s turn “module this” into a module-local special variable with a name such as `module`, `thisModule`, `currentModule`, etc.

On Jun 9, 2014, at 6:25 , Domenic Denicola <domenic at domenicdenicola.com> wrote:

> 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
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

Dr. Axel Rauschmayer
axel at rauschma.de

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140609/c20ab51b/attachment-0001.html>

More information about the es-discuss mailing list