Re: variable declarations shadowing named properties on window

On 1/5/12 1:39 PM, Travis Leithead wrote:
>>> Note that this does not obviate the need for the no-overriding-builtins
>>> stuff, though, because you don't want to shadow Object.prototype on the
>>> named props object either...
>>
>> Yeah.
>>
>>> So it might be possible to move the named props object to the other spot
>>> in the proto chain.
>
>
> I'm getting a little confused with the proposed changes here. GSP is not part of the prototype chain

Right now, that's correct.

If that's the case, then working within the ES spec there is no way to 
make var declarations override GSP properties.

So either var won't override them, or GSP needs to change to be part of 
the prototype chain.

Cameron proposed a specific way to do the latter.

> Are you thinking about this: ?
>
> Object.prototype<- Window.prototype<- [named props obj]<- window
>
> ...will break the web if that is truly the scope lookup. GSP needs to happen _last_ in the scope resolution for window.

The [named props obj] will still need the proxy behavior where name 
lookups on it check its proto chain first, of course.  That was the 
"does not obviate" part quoted above at the very beginning of the mail.

> In general, I'm against adding an observable object in the prototype chain for this behavior--I think the behavior should be associated with the instance.

Then you can't have var shadow GSP properties without some sort of 
changes to the ES spec.  There's simply no facility for doing that.

-Boris

Received on Thursday, 5 January 2012 18:45:27 UTC