Converting an existing object to a proxy

Brendan Eich brendan at mozilla.com
Fri May 27 07:21:06 PDT 2011


On May 27, 2011, at 3:04 AM, David Bruant wrote:

>> The idea of permitting this "becomes" operation only for extensible objects with configurable properties is crucial.
> Is it? The first time I heard about the "become" operation was in the context of the proxy fix trap. Second time was this message. It doesn't sounds crucial yet to me.

The "crucial" applied to both "only for extensible objects with configurable properties" in that sentence. ;-)

The issue as I understand it is not becomes per se (more below), rather that an extensible object with configurable (own) properties could have those properties wrapped by accessors to emulate some of the intercessive power of proxies. From the security point of view, you want frozen and sealed objects, at least, to be immune to proxification because they are immune to such property-by-property wrapping with accessors, today.

See Mark's reply on the list dated 7:33pm yesterday.


>> The motivation is to unify ideas in proxies (in Harmony) with those proposed in http://wiki.ecmascript.org/doku.php?id=strawman:observe.
> I hadn't read this proposal yet. Thanks.
> 
> I think that this discussion raises the following question:
> Should all usages of the "become" operation be associated with proxies?

We are not exposing becomes in the language -- certainly not for two arbitrary live objects.

In both the proxy fix case, and in this Proxy.createFrom case, one of the two objects is a newborn, not yet accessible. We brain-transplant between the accessible and inaccessible, swapping the objects' data. The identity is preserved but the internal and own properties are exchanged.

Questions about the proxify-existing-object case:

1. Won't the proxy want the original "brain", the one transplanted into a newborn proxy (now "become" the regular object)?

2. Will the costs here be acceptable compared to something unstratified requiring no extra object, a la strawman:observe?

/be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110527/29b7627b/attachment-0001.html>


More information about the es-discuss mailing list