Save Object.observe()! (please) + make WeakMap/WeakSet observable.

Tom Van Cutsem at
Wed Nov 4 21:46:04 UTC 2015

2015-11-03 15:41 GMT+01:00 Matthew Robb <matthewwrobb at>:

> 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 <

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).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list