On May 1, 2010, at 4:29 PM, Kris Kowal wrote:
On Fri, Apr 30, 2010 at 3:42 PM, Tom Van Cutsem <[email protected]>
wrote:
Hi,
I recently gave a Google tech talk on my joint work with Mark S.
Miller on
Harmony proxies and the traits.js library. Below is an abstract and
a link
to the video.
May I recommend that the "enumerate" method return a "forEach"-able
object, such that:
for (x in proxy) …
be reified as:
handler.enumerate().forEach(…)
albeit optimized for proper Arrays?
This would permit at least some degree of laziness.
See http://wiki.ecmascript.org/doku.php?id=harmony:proxies --
specifically these bulleted items near the bottom:
* Should ES-harmony support a general iterator or generator mechanism,
the interface of the enumerate trap should be aligned with that
mechanism.
. . .
* Waldemar raised objections against the current Proxy API to proxy
objects with a large number of properties. The problematic traps are
fix and enumerate. W.r.t enumerate, a proxy could return a proxy for
an array. Additionally, enumerate should be modified as soon as there
is a solid proposal for generators/iterators. Proxies for large
objects could resist being fixed. This solution is satisfactory as
long as no part of the spec depends on an object being non-extensible/
sealed/frozen.
Dave Herman and I have a generators/iterators proposal coming along --
should be up some time next week on the wiki.
I've also been working on a "handler" API for promises in CommonJS,
which has a reasonable degree of symmetry. One thing that's occurring
to me is that it is probably desirable for a generic, potentially
frozen prototype handler to be exposed so that they can be explicitly
prototypically inherited and extended. I'm not sure whether you've
specified that handlers must be records, owning all usable trap
properties, but that would preclude meta-object hierarchies. I
suspect that these will be desirable and that exposing the base
handler prototype would be useful.
Not to worry, traps are accessed as handler properties, not "own",
just "in" (so possibly in a prototype). See http://wiki.ecmascript.org/doku.php?id=harmony:proxies_semantics
. Example:
[[Get]] (P)
When the [[Get]] internal method of a trapping proxy O is called with
property name P, the following steps are taken:
1. Let handler be the value of the [[Handler]] internal property of O.
2. Let get be the result of calling the [[Get]] internal method of
handler with argument “get”.
3. If get is undefined, throw a TypeError.
4. If IsCallable(get) is false, throw a TypeError exception.
5. Return the result of calling the [[Call]] internal method of get
providing handler as the this value, O as the first argument and P as
the second argument.
Mozilla's implementation (see https://bugzilla.mozilla.org/show_bug.cgi?id=546590)
already includes a no-op handler. We envision others that can be
reused and delegated to via prototypes.
/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss