Direct proxies update

Tom Van Cutsem at
Tue Nov 29 02:59:12 PST 2011

2011/11/29 Allen Wirfs-Brock <allen at>

> Because of the invariant validation mechanism, the target needs to be a
> direct reference to a native object rather than a mirror.


> If I understand the general usage model, then in the general case it may
> not be as lean as Proxy(target,handler) regardless of whether Mirrors are
> involved.  If the handler needs to retain any per proxy instance state then
> a new handler is going to have to be instantiated for each Proxy instance
> in order to capture that state. Proxy(target, new MyHandler(args))

Indeed, although it remains possible using the current API to write
stateless handlers that maintain their state in a WeakMap keyed by their
target (or the handlers themselves).

There will indeed be cases where handlers want to maintain other state
directly. Still, there will also be cases where the handler does not need
to retain extra state, and it's a good thing that in those cases, no
additional object allocation is necessary.

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

More information about the es-discuss mailing list