Proxies with State

Brendan Eich brendan at
Tue May 31 20:46:05 PDT 2011

On May 31, 2011, at 4:57 PM, Cormac Flanagan wrote:

> One possible concern with proxies is the overhead of separate proxy
> and handler objects, and trap methods that likely close over a backing
> object.

Or weakmap proxies to backing objects.

> This concern would be exacerbated in the case of value
> proxies, where we might want millions of complex number proxies, and
> also came up in the discussion of the Observer use case last week.

The strawman at addresses this by specifying a Proxy.createValue function taking a StructType descriptor as its last argument.

This is a targeted API, not for all use-cases but specifically for the one you cite: primitive values with efficiently packed structured binary data representations and operator methods.

> It seems it would be nice to allow proxy objects to have some state.

I think Proxies hit a sweet spot by isolating handler and proxy apart from the introduction in Proxy.create{,Function}. Trying to overload them to handle state (especially efficient, co-allocated binary data) is too much.


More information about the es-discuss mailing list