On Nov 4, 2011, at 2:49 PM, Brendan Eich wrote:

> On Nov 4, 2011, at 2:40 PM, Allen Wirfs-Brock wrote:
> 
>> On Nov 4, 2011, at 2:33 PM, Brendan Eich wrote:
>>> ...
>>> If you could redefine [] as an operator on all objects, perhaps that would 
>>> help. Or hurt. Both, probably. That isn't what Allen proposes, though. It 
>>> would have to be universal AFAICT. Thoughts?
>>> 
>> 
>> Actually, that sounds pretty much what I proposed.  My proposal was that [ ] 
>> (actually RHS and LHS independently) would invoke a method using a well 
>> known property name if it was present on the object to the left of the [ ].  
>> If the property was not present (own or inherited) then it would fall back 
>> to current behavior.
> 
> 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...

Allen 



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

Reply via email to