(Mostly) transparent forwarding seems to be one of the more compelling and
generally useful characteristics of Proxies. I have to lean heavily on the
deeper knowledge of the group here, but *if* `new Proxy([], {})` otherwise
behaves like a bonafide array when you treat it like one, then it would be
a pity to lose the ability to take advantage of that over `Array.isArray()`
resolving to false. *If* transparent forwarding is an intended feature of
proxied arrays, then I'd argue it's far too common of a test to discount .
But again, I can't answer those "ifs". :)
On Fri, Nov 14, 2014 at 4:54 PM, Brendan Eich <[email protected]> wrote:
> Tom Van Cutsem wrote:
>
>> 2014-11-14 21:52 GMT+01:00 Jeremy Martin <[email protected] <mailto:
>> [email protected]>>:
>>
>>
>> Allen's previous comments:
>>
>> Proxies are not transparent forwarders! In particular their
>> default handling of the `this` value on method invokes will
>> break any built-in method that needs to access "internal
>> slots" of an object.
>>
>>
>> ...lead me to believe that this isn't the case for proxified
>> Arrays, so I'd have to reverse my earlier position, as
>> `Array.isArray(proxifiedArray)` evaluating to true just seems
>> likely to break code.
>>
>>
>> For the particular case of Arrays though, because Array methods were
>> carefully specified to be generic (i.e. to also work on non-array objects),
>> they will work just fine on proxies-for-arrays:
>>
>> var p = new Proxy([1,2,3] , {} );
>> var a = p.map(function(x) { return x + 1; });
>> console.log(a); // [2,3,4]
>>
>> So, of all the exotic objects in the ES and WebIDL specs, Arrays are
>> probably one of the few exceptions where a Proxy wrapper *is* transparent
>> by default.
>>
>
> Right.
>
> There is no all-or-nothing solution. Allen's words applie to exceptions to
> the rule. Arrays and well-written proxies for them fit in the rule. Jeremy,
> what do you say?
>
> /be
>
--
Jeremy Martin
661.312.3853
http://devsmash.com
@jmar777
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss