[Harmony Proxies] Proposal: Property fixing

David Bruant david.bruant at labri.fr
Wed Jun 15 05:19:07 PDT 2011


Le 15/06/2011 13:34, Tom Van Cutsem a écrit :
> 2011/6/14 Allen Wirfs-Brock <allen at wirfs-brock.com 
> <mailto:allen at wirfs-brock.com>>
>
>     Doesn't this new proposal still preclude using proxies to create
>     an exact emulation of the built-in Array object type.  The
>     "length" property of arrays is specified to be non-configurable
>     yet special behavior must occur each time the value of length is
>     changed.  The proposal would allow "length" to be "fixed"  as an
>     accessor property whose set behavior did the necessary processing.
>      However, that is also a violation of the Array specification as
>     it requires that "length" exhibit the attributes of a data property.
>
>
> It is true that this strawman would not enable a faithful emulation of 
> the Array "length" property at the meta-level (i.e. when looking at an 
> object as a set of property descriptors). I can't yet judge how much 
> of an issue this is: given the novelty of the property descriptor API, 
> I don't know how much code such an imperfect Array proxy would break. 
> At least at the "base-level" (i.e. regular application code), "length" 
> would be updated as expected, and remains accessible as 
> "arrayproxy.length".
>
> (As an aside: re. the emulation of arrays, having a configurable 
> [[Class]] such that |Object.prototype.toString.call(arrayproxy)| can 
> return "[object Array]" seems like a more important imperfection to fix)
I disagree. People can fix this one by themselves: 
https://gist.github.com/1026960 (I haven't tested, but it gives the 
idea). Of course this solution is valid as long as observable side 
effects of [[Class]] can be redefined.
This is not the case for the .length issue.

Cheers,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110615/3c5eb289/attachment.html>


More information about the es-discuss mailing list