On Mon, Jun 10, 2013 at 1:18 AM, Tom Van Cutsem <[email protected]> wrote:
> 2013/6/9 Dmitry Soshnikov <[email protected]> > >> >> On Jun 8, 2013, at 3:30 AM, Till Schneidereit wrote: >> >> > At the last TC39 meeting, an agreement was reached for proxies to >> support an Invoke trap. >> >> Finally (I remember that long thread 2 years ago when I was advocating >> for it). >> >> Curious what was the reasoning behind this now, since as I understand the >> invoke trap wont' be for "virtual" (non-existing methods), but still for >> real function objects returned from the invoke trap -- in order to keep >> extracting to a var invariant working. If the later should be preserved, >> then the [[Get]] should be called anyways as I see. > > > The main reason behind adding invoke() was to make rebinding |this| easy > and efficient upon forwarding, essentially to make examples such as the > following work: > > var date = new Date() > var proxy = new Proxy(date, { > invoke: function(target, name, args, rcvr) { > return target[name].apply(target, args); // note, |this| bound to > target inside forwarded method, not to |rcvr| (= the proxy itself) > } > }); > > proxy.getFullYear() // works fine, no "error: not a Date" exception > > I see, yeah, it makes sense. Thanks, I'll take a detailed look on the updated wiki page. Dmitry
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

