Le 04/05/2012 18:37, Allen Wirfs-Brock a écrit :
>
> On May 4, 2012, at 8:33 AM, David Bruant wrote:
>
>> Hi,
>>
>> Le 04/05/2012 06:42, Allen Wirfs-Brock a écrit :
>>> Common ways to configure the global environment:
>>>
>>>    Browser compat:
>>>        ES5 built-in global bindings replicated on the global object
>>>        any new ES6 built-in global bindings are not replicated on
>>> the global object
>> I disagree with this point as it makes web browsers inconsistent.
>> Some code does feature detection by testing presence on the global
>> object (since it's currently equivalent to "typeof builtinGlobalName
>> !== 'undefined'"). You're saying that the equivalent should be
>> broken, so, ES5 and ES6 features won't be feature-detectable the same
>> way.
>> I don't think there is a loss in having ES6 built-in global bindings
>> replicated on the global object. Actually, Firefox does define
>> WeakMap and Map as global object properties.
>
> "typeof builtinGlobalName"  doesn't change in anything I proposing here.
I understand, but "'WeakMap' in this" or "'WeakMap' in window" is
something people will use. That's a way of doing feature detection as well.

> From the perspective of ES code and identifier resolution there is
> simply a single global lexical contour that includes all built-ins,
> top-level declarations, and properties of the global object.  The
> "sub-environments" I'm talking about is simply a means to define the
> interactions between language induced bindings and properties of the
> global object (if there is one). It isn't at all clear to me why
> WeakMap, Map, or any other future ES global binding should be
> polluting the property name space of the DOM window object.
It isn't to me either why 'Array' pollutes the DOM window object, but
that's how it's been implemented.

> Why is referencing window.WeakMap a good idea?
>From an absolute standpoint, I don't think it is, we agree on that. But
it would just make new features consistent with old features. For a
newcomer to the language 15 years from now, it will be inconsistent to
realize that for built-ins, some identifier have a global object
property counterpart and some don't.
The only reason that makes a "WeakMap" global object property a "good
idea" is consistency. That's also how it's currently implemented in
Firefox and Chrome.

Acknowledging that built-in identifiers are aliased as global object
properties in web browsers, what is the downside of continuing?

David
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to