[Harmony Proxies] Non-extensible, sealed and frozen Proxies

Tom Van Cutsem tomvc.be at gmail.com
Thu Sep 8 07:55:30 PDT 2011

2011/9/8 David Bruant <david.bruant at labri.fr>

> **
> So the third argument would be the object the proxy would become. This
> sounds like a reasonable idea but is a bit different from the original fix
> proposal which created a fresh object based on an object description
> (pdmap).
> I guess I should ask: why in the original design did the author had to
> return a description of the object to be returned rather than creating the
> object himself and return it? To avoid returning a proxy, maybe?

In order for the proxy to safely "become" a target object, the target object
should be newborn (i.e. no other object should have a live reference to the
target object). Otherwise, we violate the stability of ===. Consider:

var o = {};
var p = Proxy.create(handler, proto, o);
o === p // false
Object.preventExtension(p); // assume p now becomes o
o === p // true

That's why fix() returns a description of a fresh object to create, rather
than a fresh object itself.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110908/f318e918/attachment.html>

More information about the es-discuss mailing list