Re: Why Proxy "apply" trap limited to function only?

2016-03-02 Thread Isiah Meadows
Oh. I didn't realize that. On Thu, Mar 3, 2016, 00:08 Kevin Smith wrote: > > I thought `typeof (class {}) === "function"` as well. And classes, to my >> knowledge aren't callable. >> > Oh they are, they just throw when you call them : ) > > >

Re: Why Proxy "apply" trap limited to function only?

2016-03-02 Thread Kevin Smith
> I thought `typeof (class {}) === "function"` as well. And classes, to my > knowledge aren't callable. > Oh they are, they just throw when you call them : ) https://tc39.github.io/ecma262/#sec-ecmascript-function-objects-call-thisargument-argumentslist Step 2

Re: Why Proxy "apply" trap limited to function only?

2016-03-02 Thread Isiah Meadows
I thought `typeof (class {}) === "function"` as well. And classes, to my knowledge aren't callable. On Wed, Mar 2, 2016, 10:09 Mark S. Miller wrote: > We maintain the invariant that the typeof of an object is stable -- it > never varies over time. An object is callable iff

Re: Why Proxy "apply" trap limited to function only?

2016-03-02 Thread Mark S. Miller
We maintain the invariant that the typeof of an object is stable -- it never varies over time. An object is callable iff its typeof is 'function'. By making the callability *and* the typeof of the proxy dependent on its target, the two stay consistent. On Wed, Mar 2, 2016 at 6:51 AM, Олег

Re: Why Proxy "apply" trap limited to function only?

2016-03-02 Thread Claude Pache
> Le 2 mars 2016 à 15:47, Caitlin Potter a écrit : > > You’re right. I would argue this warrants a non-normative pointer to > ProxyCreate() in the proxy [[CALL]] and [[CONSTRUCT]] internal methods. > > Thanks! Bug reported here:

Re: Why Proxy "apply" trap limited to function only?

2016-03-02 Thread Олег Галабурда
> > > Rather, I'd say it is a bug in Chromium. > > A Proxy should have a [[Call]] internal method if and only if its target > has a [[Call]] internal method. See: > > http://www.ecma-international.org/ecma-262/6.0/#sec-proxycreate step 7. > > That maintains the equivalence: `typeof x ==

Re: Why Proxy "apply" trap limited to function only?

2016-03-02 Thread Caitlin Potter
You’re right. I would argue this warrants a non-normative pointer to ProxyCreate() in the proxy [[CALL]] and [[CONSTRUCT]] internal methods. Thanks! > On Mar 2, 2016, at 9:44 AM, Claude Pache wrote: > >> g signature.asc Description: Message signed with OpenPGP using

Re: Why Proxy "apply" trap limited to function only?

2016-03-02 Thread Олег Галабурда
Yes, correct. I want to be able to make a callable Proxy for non-callable objects and don't understand why Proxies are having these restrictions. As you can see I, and any other developer, can easily bypass this restriction and make a wrapper function that actually will be never called and just

Re: Why Proxy "apply" trap limited to function only?

2016-03-02 Thread Claude Pache
> Le 2 mars 2016 à 15:36, Caitlin Potter a écrit : > > As far as I can tell, this is a bug in Firefox / SpiderMonkey. The [[CALL]] > internal method of Proxy objects does not impose any restriction on the type > of the Proxy target. > > The following code behaves

Re: Why Proxy "apply" trap limited to function only?

2016-03-02 Thread Caitlin Potter
As far as I can tell, this is a bug in Firefox / SpiderMonkey. The [[CALL]] internal method of Proxy objects does not impose any restriction on the type of the Proxy target. The following code behaves correctly in Chromium: ```js var proxy = new Proxy({}, { apply(target, thisArgument,

Re: Why Proxy "apply" trap limited to function only?

2016-03-02 Thread Claude Pache
> Le 2 mars 2016 à 13:21, Олег Галабурда a écrit : > > Hi! > > I'm currently working on project that allows to manipulate objects passed > from Worker. > https://github.com/burdiuz/js-worker-interface > > > It creates

Re: Why Proxy "apply" trap limited to function only?

2016-03-02 Thread Олег Галабурда
As I uderstood, here, in the spec it states that if target is "function", then trap "apply" is available, to catch function invocations http://wiki.ecmascript.org/doku.php?id=harmony:virtual_object_api And that's how it behaves in Forefox -- it just ignores "apply" trap if target object is not a

Re: Why Proxy "apply" trap limited to function only?

2016-03-02 Thread Caitlin Potter
What exactly do you mean by “restricted to functions only”? > On Mar 2, 2016, at 7:21 AM, Олег Галабурда wrote: > > Hi! > > I'm currently working on project that allows to manipulate objects passed > from Worker. > https://github.com/burdiuz/js-worker-interface >

Why Proxy "apply" trap limited to function only?

2016-03-02 Thread Олег Галабурда
Hi! I'm currently working on project that allows to manipulate objects passed from Worker. https://github.com/burdiuz/js-worker-interface It creates wrapper objects that record actions applied to this object and send commands to Worker. The problem is, when request is made I cannot know what