"var" declarations shadowing properties from Window.prototype
allen at wirfs-brock.com
Sat Aug 11 18:41:04 PDT 2012
On Aug 11, 2012, at 6:12 PM, Cameron McCormack wrote:
> Jonas Sicking:
>>> Webkit also puts attributes on objects for non-globals, but I'm not
>>> promoting that behavior. Nor do I know of any benefits regarding web
>>> compatibility that comes with that behavior.
> Brendan Eich:
>> Ok, that's what I was getting at. It may be that this is just historical
>> consistency for all objects, no global exception, but sounds like we are
>> agreeing that the global object needs an exception ("own" promotion of
>> attributes and methods) in WebIDL.
> Before ES5 was out, Web IDL put properties for IDL attributes on instances, exposed via special [[Get]] and [[Put]] behaviour. That was pretty much what implementations were doing. Once ES5 standardised accessor properties, we had the opportunity to make IDL attributes less magical -- which was argued for pretty strongly by TC39 folks, before Proxies came along. Now perhaps I didn't consider closely enough the possibility of this being a breaking change (especially on the global object), but it seemed everyone was happy enough with moving in that direction. And I think it's a cleaner model for shared properties with getter/setter behaviour, anyway, and gives you the opportunity to monkeypatch them that the special [[Get]] and [[Put]] behaviour couldn't.
> Which is to say that I think we should still push forward with attributes-as-accessor-properties-on-prototypes at least for objects other than the global object.
Exactly, attributes-as-accessors-on-prototypes seems to work great for everything other than the global object. But for the global object, attributes and operators are essentially equivalent to ES declared or built-in global variables/functions. The global object has a special role. It's fine to special case its treatment of WebIDL attributes and operators.
More information about the es-discuss