Question about direct proxies syncing their targets

Tom Van Cutsem tomvc.be at gmail.com
Mon Jan 16 08:17:16 PST 2012


2012/1/14 Tab Atkins Jr. <jackalmage at gmail.com>

> In the direct proxies proposal at
> <http://wiki.ecmascript.org/doku.php?id=harmony:direct_proxies>,
> there's the following line:
>
> get:
>  * Invariant checks:
>    * if property exists on target as a data property, updates the
> target’s property with the returned value
>

This is a bug, a remnant of an earlier design in which a direct proxy would
indeed keep the target "in sync" with the handler. In the current design
(and draft spec, see <
http://wiki.ecmascript.org/doku.php?id=harmony:proxies_spec>) direct
proxies only verify the invariants, they never actively update their target
anymore.

I updated the invariant checks for get and set on the wiki page.


> Consider an xrange object like from Python, which represents a numeric
> range (with a start, stop, and step) and exposes both an iterator and
> get traps.
>
> Am I correct in assuming that, since the target of an xrange proxy is
> an empty object, iterating through the xrange or getting specific
> values from it will *not* fill up the target in an attempt to
> synchronize it with the returned values from the get trap?
>

That's right: the proxy will not fill up the target. As David noted, this
is primarily because you're exposing values for properties that don't exist
on the target, so no invariants w.r.t. non-configurability have to be
upheld anyway. But even in the current design, the proxy will never
implicitly fill up the target. Rather, it would throw a TypeError when
detecting an inconsistency.

Thanks for posting.

Cheers,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120116/0cef7ef7/attachment.html>


More information about the es-discuss mailing list