Proxy target as __proto__? (Re: Proxy's optional target)

Claus Reinke claus.reinke at talk21.com
Thu Jan 17 13:14:08 PST 2013


> The proxy target is important because it specifies some invariants 
> about the proxy (typeof, builtin brand, behavior of forwarding for 
> unspecified traps, values of internal properties like [[DateValue]], 
> [[NumberValue]], etc.).

That is probably the most important difference between direct
proxies and old-style proxies. Yet I find it slightly limiting and
accident-prone: it uses invariants and target to make proxies
not just behave like an object, but to behave like the target.

Presentations on direct proxies tend to present too usage 
patterns: wrapped objects and virtual objects.

My problem is: if I am using proxies as wrappers, I want to use
the target object as a -wait for it- prototype, to be *modified* by
the proxy. But if the target object happens to be frozen, modified 
returns are no longer allowed by the invariants. To cover this
eventuality, I should use the virtual object pattern even if I
just want to wrap an object!

Would it be possible/helpful to use the target merely as a 
__proto__ instead of a harness, inheriting the target's internal 
properties without over-constraining the proxy's ability to
modify the wrapped target's behavior? Invariants could still 
use an implied object for freezing the *proxy*, so the proxy 
would behave as an object, not necessarily the same as the 
target object.

Claus
 


More information about the es-discuss mailing list