Typo in direct proxy proposal for the apply trap

# David Bruant (13 years ago)

In the proxy proposal, one can read the following signature for the apply trap: apply: function(target,receiver,args) -> any

But the "receiver" doesn't make much sense to me. Is it just a typo or am I missing something?

David

[1] harmony:direct_proxies

# Rick Waldron (13 years ago)

On Sun, Sep 2, 2012 at 1:57 PM, David Bruant <bruant.d at gmail.com> wrote:

Hi,

In the proxy proposal, one can read the following signature for the apply trap: apply: function(target,receiver,args) -> any But the "receiver" doesn't make much sense to me. Is it just a typo or am I missing something?

Based on the older proposals, the receiver is a thisArg that is usually just a reference to the Proxy

# David Bruant (13 years ago)

Le 02/09/2012 20:38, Rick Waldron a écrit :

On Sun, Sep 2, 2012 at 1:57 PM, David Bruant <bruant.d at gmail.com <mailto:bruant.d at gmail.com>> wrote:

Hi,

In the proxy proposal, one can read the following signature for the
apply trap:
apply:  function(target,receiver,args) -> any
But the "receiver" doesn't make much sense to me. Is it just a typo or
am I missing something?

Based on the older proposals, the receiver is a thisArg that is usually just a reference to the Proxy

Ok, it makes a lot of sense. I think I had been confused by the example "proxy(...args)". It probably should be something like "proxy.apply(receiver, args)" to refer to receiver.

Thanks,

# Brandon Benvie (13 years ago)

The use of the term receiver is somewhat misleading when put next to the receiver in the get and set traps. For get and set the receiver is always the proxy unless it's an object that has the proxy as its [[prototype]]. For function invocation the receiver is the callsite object which is never going to be the proxy itself (unless you did something like fnproxy.call(fnproxy).

# David Bruant (13 years ago)

Le 02/09/2012 23:13, Brandon Benvie a écrit :

The use of the term receiver is somewhat misleading when put next to the receiver in the get and set traps. For get and set the receiver is always the proxy unless it's an object that has the proxy as its [[prototype]]. For function invocation the receiver is the callsite object which is never going to be the proxy itself (unless you did something like fnproxy.call(fnproxy).

Indeed. I spent some time yesterday playing with the direct proxy Firefox implementation and adjusting the Proxy doc on MDN [1] (which is why I spammed es-discuss with proxy-related topics). I chose not to use "receiver" in the doc, but "thisValue" instead.

David

[1] developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Proxy

# Tom Van Cutsem (13 years ago)

"receiver" is indeed a bit of a misnomer for the apply trap. "thisArg" is more sensible. I'll update the wiki page.

You probably missed it, but the role of the "thisArg"/"receiver" parameter is described by example using the following code snippets on the direct proxies wiki page:

proxy(...args); // triggers handler.apply(fun, undefined, args) var obj = { m: proxy }; obj.m(...args); // triggers handler.apply(fun, obj, args) Function.prototype.apply.call(proxy, rcvr, args); // triggers handler.apply(fun,rcvr,args)

Cheers, Tom

2012/9/3 David Bruant <bruant.d at gmail.com>