default this binding for ES-next strict mode.

Jake Verbaten raynos2 at gmail.com
Fri Nov 18 13:51:24 PST 2011


On Fri, Nov 18, 2011 at 9:30 PM, Axel Rauschmayer <axel at rauschma.de> wrote:

> > What if we changed the value of `this` inside local function
> declarations to be the value of this in the outer function.
>
> I’d love this to work!
>
> Alas, the value of `this` has to be determined dynamically. Mark Miller
> gave a good example why that’s bad (when I recently suggested the same
> thing):
> http://www.mail-archive.com/es-discuss@mozilla.org/msg11194.html


I don't think that's neccessarily a bad thing. If you ask me, it's a poor
counter example because innerPoint should not be defined inside Outer.

I defiantly see the problem with the value of `this` leaking through any
closures you return. I'm not sure whether this is particularly bad. It's
just something people need to be aware of.

Of course this adds two more cons

Cons:
 - outer value of `this` leaks through returned closures
 - code that used to throw an error, will now work with unexpected side
effects.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111118/50ed0e1d/attachment.html>


More information about the es-discuss mailing list