How to escape implicit 'with (this)' of a method body
P T Withington
ptw at pobox.com
Tue Jul 29 06:18:41 PDT 2008
On 2008-07-29, at 01:19EDT, Brendan Eich wrote:
> On Jul 28, 2008, at 10:05 PM, Jon Zeppieri wrote:
>
> The original code used "without (this)", not "with", which I took to
> mean "avoid instance properties shadowing globals".
Indeed. Perhaps I was being too clever in my pseudo-code.
> If you read the original as "with", then there is no such problem.
> But if you construct a problematic case using 'with' and dynamic
> properties, then I concede that 'global' could be shadowed. This is
> a reason to avoid 'with'. In the ES4 proposals last sent out, you
> could always use __ES4__::global if you really wanted to avoid
> conflicts -- unless someone perversely added '__ES4__' as a dynamic
> instance property.
>
> There's no solution to this problem other than reserving at least
> one name, and we can't do that compatibly. We could reserve __ES4__
> in version-selected ES4 mode, but that seems unnecessary.
I guess this is considered a small penalty to pay in exchange for
adding the magical instance scope to methods (which O-O programmers
seem to expect these days). Something we'd regret more if we had
multi-methods, perhaps...
More information about the Es4-discuss
mailing list