>> So Object.prototype customization would cover all cases? Except Proxies, of 
>> course -- and host objects.
> 
> Yes, except that what you would expect to put into Object.prototype would 
> actually (or also) be defined as default behavior in order to ensure that 
> that Object.create(null) objects, etc continue to have ES1-5 behavior.  
> Because collection behavior is defined via  method invocation, proxies don't  
> need to do/have anything special (although a Proxy's [[Get]] handler) could 
> look for accesses to the special [ ] behavior methods.  Same for host 
> objects, except who knows what a host object really is...

Have you come to a decision with regard to a separate .[] operator for 
collections (including arrays)?

I think it’s better to rededicate []:
- .[] would invalidate all existing array code.
- [] would only invalidate code that uses computed property names. And that can 
be fixed via the default behavior.

It might make sense to have a "stricter mode" that turns off the default 
behavior of []:
- It would thus force you to use methods such as (the yet to be defined) 
Object.setOwnProperty() and Object.getProperty() when you want to compute the 
name of a property.
- Stricter mode could also restrict [] for arrays to just numbers, including 
negative numbers for accessing elements relative to the end of an array.

-- 
Dr. Axel Rauschmayer
a...@rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com



_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to