[Harmony Proxies] Proposal: Property fixing

Tom Van Cutsem tomvc.be at gmail.com
Tue Jun 14 01:57:49 PDT 2011


Hi,

To address the outstanding issue of how proxies should deal with
non-configurable properties, I picked up on Sean's earlier proposal, adapted
it and turned it into a strawman: <
http://wiki.ecmascript.org/doku.php?id=strawman:fixed_properties>.

My adaptation is more permissive than the original proposal in that it still
allows proxies to intercept access to non-configurable properties if they
are willing to expose them as accessor rather than data properties.

This proposal would allow proxies to cover more use cases (because they can
now emulate non-configurable properties), at the expense of additional
complexity within proxy objects.

As always, discussion and feedback are appreciated.

Cheers,
Tom

2011/5/4 Sean Eagan <seaneagan1 at gmail.com>

> What:
>
> Honor attempts to make individual proxy properties non-configurable.
>
> Why:
>
> For consistency since attempts to make *all* of a proxy's properties
> non-configurable are honored via the "fix" trap.
>
> Example:
>
> var x = Proxy.create({
>  defineProperty: function() {},
>  getPropertyDescriptor: function() {
>    return {
>      value: "whatever I want",
>      writable: true,
>      configurable: true,
>      enumerable: false
>    };
>  }
> });
> Object.defineProperty(x, "foo", {value: "bar", configurable: false,
> writable: false, enumerable: true};
>
> /* ... */
>
> // logs "whatever I want", not "bar"
> console.log(x.foo);
> // non-writable, but doesn't throw
> object.foo = "baz";
> // non-configurable, but doesn't throw
> Object.defineProperty(x, "foo", {configurable: true});
>
> How:
>
> Assume a "defineProperty" trap invocation due to
> |Object.defineProperty(proxy, name, pd)| where |!pd.configurable|.  If
> return value is...
>
>  true - Henceforth bypass |proxy|'s handler for any traps with a
> property name parameter when the property name would be |name|
>  false - throw TypeError similarly to "fix" trap
>
> Update the "fix" trap semantics such that when its return value is not
> undefined but rather a property descriptor map, behavior is similar to
> |Object.defineProperties| in that improperly redefining any properties
> will cause a TypeError to be thrown.
>
> Notes:
>
> Can check |Object.getOwnPropertyDescriptor(proxy, name).configurable|
> to determine if a given proxy property is fixed since it will always
> be false in this case.
>
>
> Thanks,
> Sean Eagan
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110614/d6867194/attachment.html>


More information about the es-discuss mailing list