[Harmony Proxies] Proposal: Property fixing

Tom Van Cutsem tomvc.be at gmail.com
Wed May 18 07:28:48 PDT 2011


2011/5/12 David Bruant <david.bruant at labri.fr>

> Le 12/05/2011 14:40, Tom Van Cutsem a écrit :
> > controversial invariant:
> >
> > - proxies can't emulate non-configurable properties. If they would,
> > proxies could still update attributes of non-configurable properties.
> >
> Currently, proxies can emulate configurable properties (they are forced
> to, but that's not my point). Still, a proxy can ignore
> Object.defineProperty calls in the case of a re-configuration and also
> ignore deletions, giving the impression that the property is
> non-configurable even though Object.getOwnPropertyDescriptor would say
> that configurable is set to "true".
> Proxies being able to lie about configurability is the exact mirror of
> proxies being able to lie about non-configurability. However, one is
> allowed, the other isn't.
>

Good point. However, Mark's distinction between eternal and momentary
invariants sheds some light on the differences. According to Mark's
classification, configurable:false comes with eternal guarantees, while
configurable:true does not. In other words: any assumptions that a program
makes that are based on the fact that a property is configurable are
necessarily momentary, since the property can become non-configurable
later. The reverse is not true.


> I need to think more about the rest of your message.
> Good work on the invariant enumeration. It may be incomplete as you
> point out, but that's a good start anyway.
>
> Among the enforced invariants, maybe that "property names being strings"
> could be added if that is enforced. If it is, it requries to cast all
> property names arguments to strings before trap calls. However,
> enforcing this invariant may require to do the same on the array
> returned by get{Own}PropertyNames/enumerate/keys. (maybe that it should
> rather be in the controversial part :-) )
>

Proxies do coerce all property names to strings, e.g. proxy[obj] will
trigger the 'get' trap with 'obj' coerced to a String. This is not actually
enforced by the proxy spec, but rather by ES5 (e.g. [[Get]] assumes that its
argument P is bound to a property name (a String)). At one point we
suggested removing this restriction, so that "proxy[obj]" would give the get
trap direct access to obj (which would be particularly useful when
intercepting numeric indices on array-like proxies). IIRC, we didn't pursue
this option since engines rely on property names being strings in other
places, and widening the type of property names to cover arbitrary objects
would be problematic.

Cheers,
Tom


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


More information about the es-discuss mailing list