2015-11-03 15:41 GMT+01:00 Matthew Robb <[email protected]>: > I probably have a terrible understanding of how this all works at a low > level but I feel like a potential solution would be a method of "upgrading" > a non-proxy object to be a proxy. The reason accessors are being used as > they are now is because you can retro fit them. Maybe what I am suggesting > is essentially like swapping out the internal pointer of an object with > another object (such as the way live module bindings work). In this way you > might upgrade an existing object to behave like a proxy. >
This feature was proposed (under the name Proxy.startTrapping) back in 2011-2012. See < https://web.archive.org/web/20140426153405/http://wiki.ecmascript.org/doku.php?id=strawman:direct_proxies#proxy.starttrapping_a.k.a._proxy.attach >. The two arguments that killed it, IIRC: 1) If a module A hands out a reference to, say, a function f to modules B and C, then C could use this primitive to replace f with its own proxied version. Module B expects f to work as A intended, but module C can completely override its behavior, stealing any arguments to the function that B would pass. This is really bad behavior from a security and modularity perspective. 2) As Brendan mentioned, implementing this primitive requires a Smalltalk-like "become:" that can swap object identities. This can be really tricky or costly to implement (highly dependent on how objects are represented in the VM). Cheers, Tom
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

