2011/9/8 David Bruant <[email protected]>
> **
> 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.
Cheers,
Tom
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss