[Harmony proxies][Terminology] "fixed" state of a proxy

David Bruant bruant at enseirb-matmeca.fr
Sun Mar 13 10:08:04 PDT 2011


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 suggestto renamethe
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110313/fbf246f7/attachment.html>


More information about the es-discuss mailing list