[Harmony Proxies] Proposal: Property fixing

Tom Van Cutsem tomvc.be at gmail.com
Wed Jun 15 14:01:27 PDT 2011

Just realized: even though an arrayProxy could update its fixed "length"
property, it would not be able to intercept updates "from the outside" (i.e.
updates to "length" by objects other than the handler). I guess that
capability is also needed to be able to "shrink" an array if its "length" is

Perhaps the strawman should be refined such that the defineProperty trap is
triggered even on redefinition of fixed properties. The trap's returned
descriptor would again act as the "real" descriptor that is used to redefine
the actual fixed property inside of the proxy using the built-in
[[DefineOwnProperty]] algorithm.


2011/6/15 Tom Van Cutsem <tomvc.be at gmail.com>

> 2011/6/15 Brendan Eich <brendan at mozilla.com>
>> On Jun 15, 2011, at 8:51 AM, Allen Wirfs-Brock wrote:
>> > More generally, for better or worse, Cameron McCormack is right now
>> busily working to publish the last call draft of a Web IDL specification
>> that includes rules for what the attribute settings must be for all DOM
>> properties.  If those rules don't match up with what proxies can express
>> then there will be issues with implementing the DOM in ECMAScript.
> Aside from the configurable attribute (which we are now discussing),
> proxies are able to emulate all other attribute values, so I can't
> immediately think of any other use cases that proxies currently cannot deal
> with.
>> Paging Dr. Van Cutsem!
>> To emulate length as non-configurable but magically changing its value as
>> a data property may be possible with proxies. It is after all writable.
> Ah, good suggestion. The fixed properties strawman would indeed allow this.
> First, one defines "length" as a non-configurable property on a fresh
> arrayProxy, thereby fixing the property:
> Object.defineProperty(arrayProxy, "length",
>   { value: 0,
>     writable: true,
>     enumerable: false,
>     configurable: false });
> Given that we provide all traps with a reference to the proxy they're
> currently servicing (as per one of the pending strawmen), the handler for
> arrayProxy can then update the fixed "length" property within a trap by
> performing:
> Object.defineProperty(arrayProxy, "length", { value: newValue });
> This will modify the fixed property, which is legal since it is writable.
> It may not be very elegant, but at least it's doable.
> To be clear: what the strawman still doesn't allow is that a proxy would be
> able to emulate a non-writable, non-configurable data property whose value
> can still change.
> Cheers,
> Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110615/b4b67e16/attachment.html>

More information about the es-discuss mailing list