There is a little twist to this. You can create a proxy that has separate
implementations of [[Call]] and [[Construct]], and by fixing it, it converts to
a regular functions. However, this "regular" function is different from any
other non-host function: it behaves different w.r.t. to f() and new f(). At the
implementation level this is reflected by the fact that we use a different
internal class for these "function" objects. It also maintains all the other
behaviors of the original proxy [[Call]] and [[Construct]] hooks, i.e. new f()
can return "5". I am not sure whether this difference warrants talking about
fixed proxies, but I wanted to point it out.
Andreas
On Mar 13, 2011, at 10:08 AM, David Bruant wrote:
> Hi,
>
> I would like to discuss the terminology of the proposal and the two states of
> a proxy: trapping or fixed.
> In order to discuss, here is a little example:
> ---------------------------------
> var o = {};
> var p = Proxy.create( forwardingHandler(o) );
> p.a = 1;
> o.b = 2;
> p.c = 3;
> o.d = 4;
> /* For all x in [a,b,c,d], we have (p[x] === o[x]) and (p.hasOwnProperty(x)
> iff o.hasOwnProperty(x)) */
>
> Object.preventExtension(p); // The "proxy" becomes "fixed"
>
> delete o.a;
> delete p.b;
> // o is like {b:2, c:3, d:4} while p is like {a:1, c:3, d:4}
> // o and p have lost "synchronicity". p is an object with its own independent
> life.
> ----------------------------------
>
> After the Object.preventExtension|seal|freeze call, p isn't a proxy anymore.
> It becomes a regular object. None of what used to be p's traps when it /was/
> a proxy is going to be called anymore through p surface-syntax iteraction.
> After the call to a succeeding (non-throwing) fix trap, what we have falls
> under the definition of an Object as known in ES5 (and previously). Another
> way to put it is that there is no way for an external program to distinguish
> if p is a proxy or an object (unless this external program had overriden
> Proxy.create beforehand).
>
> The way I see it, a proxy is trapping and that's it. What is "fixed" is an
> object, because the proxy has lost all its "magic" (and cannot get it back by
> design).
>
> In my opinion, we should stop talking of proxies as "fixed" and stop using
> this terminology because it may cause confusion.
> If there is an agreement on this, I'd suggest to rename the Proxy.isTrapping
> method as Proxy.isProxy since as I understand it, saying that a proxy is
> trapping is a tautology.
>
> What's your opinion?
>
> David
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss