Notification proxies experiment
Tom Van Cutsem
tomvc.be at gmail.com
Thu Jan 17 05:36:05 PST 2013
I've been working on implementing Notification proxies as originally
proposed by Dean Tribble on this list  and then later expanded upon .
In a nutshell, their history is somewhat as follows:
1) original proxies could not emulate non-extensible objects or objects
with non-configurable properties
2) direct proxies, by directly wrapping a specific target object, allow
safe emulation of such objects/properties but at the expense of complex
3) notification proxies aim to get rid of invariant checks by only
notifying the handler that an operation was performed on the proxy, and
then automatically forwarding to the real target. The handler doesn't get
to influence the result of an intercepted operation. Traps essentially
become just notification callbacks (although the notification is
See the readme for details:
There's also two examples: a generic logging proxy that just logs all
intercepted operations, and a revocable reference, expressed as a
For these two examples, notification proxies work out very well. They're
even simpler than direct proxies because there's no need to manually
The notification proxy implementation (on top of old proxies) is also
significantly simpler compared to direct proxies, so notification proxies
are probably a lot simpler to specify as well.
The remaining challenge with notification proxies is how to implement
proxies where always forwarding all operations automatically does not make
sense. Examples include membranes (need to wrap the result), and perhaps
self-hosted exotics that aren't backed by any real "target". I haven't yet
gotten around to implementing those. If anyone is willing to give it a try
in the mean time, this would lead to valuable feedback.
I realize we're close to the ES6 deadline and this would be a big change to
proxies. At this time I'm not seriously proposing notification proxies as
an alternative to direct proxies. We need more experience with them first.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss