[[Invoke]] vs [[Get]]

Dmitry Soshnikov dmitry.soshnikov at gmail.com
Mon Jun 10 11:09:36 PDT 2013


On Mon, Jun 10, 2013 at 1:18 AM, Tom Van Cutsem <tomvc.be at gmail.com> wrote:

> 2013/6/9 Dmitry Soshnikov <dmitry.soshnikov at gmail.com>
>
>>
>> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130610/9702a35b/attachment.html>


More information about the es-discuss mailing list