Membranes, unmediated access to objects through Object.getPrototypeOf

Tom Van Cutsem tomvc.be at gmail.com
Tue Oct 9 12:01:08 PDT 2012


2012/10/9 Mark S. Miller <erights at google.com>

> On Tue, Oct 9, 2012 at 6:25 AM, David Bruant <bruant.d at gmail.com> wrote:
>
>> In a way, what I'm asking is to make dummy target "official" and more
>> restricted, by not allowing arbitrary objects, but only proxies with the
>> actual target in their target chain.
>>
>
> Making them more official and restricted sounds promising. But if I
> understand the rest of your sentence, what you're suggesting is not more
> restricted, it's differently restricted. And the way it is less restricted
> is, IMO, bad.
>

To make matters more concrete, one way in which the chaperone-approach
would differ visibly from the current state has to do with caching. As Mark
said, the invariants related to getPrototypeOf and frozen properties have
more to do with stability than with identity.

Valid approach today:

var desc = Object.getOwnPropertyDescriptor(obj, "foo");
// assume "foo" is a data property
if (!desc.configurable && !desc.writable) {
  var cached = obj.foo;
  /* from now on, can reliably use cached instead of obj.foo */
}

If we would relax the frozen property get invariant, if obj is a proxy,
obj.foo could evaluate to a different proxy (admittedly to the same target)
even though "foo" is non-configurable, non-writable. This can lead to
observably different behavior.

(getPrototypeOf is analogous)

Cheers,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121009/c3d105e4/attachment.html>


More information about the es-discuss mailing list