Re: Calling toString on function proxy throws TypeError exception

2015-10-28 Thread Tom Van Cutsem
2015-10-27 12:47 GMT-04:00 Jordan Harband : > > Shouldn't tests in existing code that rely on `Function#toString` not > throwing to indicate that something is callable, or throwing to indicate > that it is not, remain true for a function proxy? > Excluding some host objects (as

Re: Calling toString on function proxy throws TypeError exception

2015-10-27 Thread Claude Pache
> Le 26 oct. 2015 à 20:20, Allen Wirfs-Brock a écrit : > > >> On Oct 26, 2015, at 11:20 AM, Mark Miller wrote: >> >> I like the idea a function proxy is more encapsulating of its implementation >> than a function is. >> >> I also like the idea of

Re: Calling toString on function proxy throws TypeError exception

2015-10-27 Thread Claude Pache
> Le 27 oct. 2015 à 09:35, Claude Pache a écrit : > > >> Le 26 oct. 2015 à 20:20, Allen Wirfs-Brock a écrit : >> >> >>> On Oct 26, 2015, at 11:20 AM, Mark Miller wrote: >>> >>> I like the idea a function proxy is more

Re: Calling toString on function proxy throws TypeError exception

2015-10-27 Thread Boris Zbarsky
On 10/27/15 4:35 AM, Claude Pache wrote: it is that, for any callable object, it will return a string and not throw, because it was so since the dawn of JS. It's totally false for random "host objects" with a [[Call]] in ES5, per spec and in at least some implementations. As you can tell in

Re: Calling toString on function proxy throws TypeError exception

2015-10-27 Thread Boris Zbarsky
On 10/27/15 9:14 AM, Boris Zbarsky wrote: On 10/27/15 4:35 AM, Claude Pache wrote: it is that, for any callable object, it will return a string and not throw, because it was so since the dawn of JS. It's totally false for random "host objects" with a [[Call]] in ES5, per spec and in at least

Re: Calling toString on function proxy throws TypeError exception

2015-10-27 Thread Mark S. Miller
Notice that whatever we decide on the issue, functionProxy.toString() will work regardless, since you'd be getting the toString method itself through the membrane. functionProxy.toString will be a function proxy for the target.toString method. The invocation on the toString proxy with

Re: Calling toString on function proxy throws TypeError exception

2015-10-27 Thread Jordan Harband
Mark: considering that explicitly invoking a builtin prototype method, expecting a throw, to test for the [[Call]] internal slot, was the branding approach the committee agreed to preserve when it reaffirmed Symbol.toStringTag, as an alternative to `Object#toString.call`, I think Claude's point

Re: Calling toString on function proxy throws TypeError exception

2015-10-27 Thread Claude Pache
> Le 27 oct. 2015 à 15:52, Mark S. Miller a écrit : > > Notice that whatever we decide on the issue, functionProxy.toString() will > work regardless, since you'd be getting the toString method itself through > the membrane. functionProxy.toString will be a function proxy

Re: Calling toString on function proxy throws TypeError exception

2015-10-27 Thread Mark Miller
Non-membraned proxies are irreparably non-transparent. This case is not worth worrying about. On Tue, Oct 27, 2015 at 1:05 PM, Claude Pache wrote: > > > Le 27 oct. 2015 à 15:52, Mark S. Miller a écrit : > > > > Notice that whatever we decide on the

Re: Calling toString on function proxy throws TypeError exception

2015-10-27 Thread Allen Wirfs-Brock
> On Oct 27, 2015, at 2:37 AM, Claude Pache wrote: > > > Naturally, I meant: > > ```js > Function.isGenerator = function (f) { > return typeof f == "function" && f.toString().match(/^function\s*\*/) != > null > } > ``` > > —Claude > >> >> That function will work

Re: Calling toString on function proxy throws TypeError exception

2015-10-27 Thread Boris Zbarsky
On 10/27/15 12:47 PM, Jordan Harband wrote: I think Claude's point ("The expectation is not that `F.p.toString` will always return something useful; it is that, for any callable object, it will return a string and not throw, because it was so since the dawn of JS.") is the one that convinces me.

Re: Calling toString on function proxy throws TypeError exception

2015-10-27 Thread Claude Pache
> Le 27 oct. 2015 à 18:41, Allen Wirfs-Brock a écrit : > > > That said, I think it is plausible that the predicate in step 2 of > http://tc39.github.io/ecma262/#sec-function.prototype.tostring > could be

Re: Calling toString on function proxy throws TypeError exception

2015-10-27 Thread Claude Pache
> Le 27 oct. 2015 à 14:14, Boris Zbarsky a écrit : > > On 10/27/15 4:35 AM, Claude Pache wrote: >> it is that, for any callable object, it will return a string and not throw, >> because it was so since the dawn of JS. > > It's totally false for random "host objects" with a

Re: Calling toString on function proxy throws TypeError exception

2015-10-26 Thread Allen Wirfs-Brock
> On Oct 26, 2015, at 11:20 AM, Mark Miller wrote: > > I like the idea a function proxy is more encapsulating of its implementation > than a function is. > > I also like the idea of treating a function proxy as a builtin callable, > rather than a function written in JS,

Re: Calling toString on function proxy throws TypeError exception

2015-10-26 Thread Mark Miller
Only because typeof f === 'function' divides the world into callables and non callables. On Oct 26, 2015 3:20 PM, "Allen Wirfs-Brock" wrote: > > > > On Oct 26, 2015, at 11:20 AM, Mark Miller wrote: > > > > I like the idea a function proxy is more

Re: Calling toString on function proxy throws TypeError exception

2015-10-26 Thread Allen Wirfs-Brock
> On Oct 23, 2015, at 6:43 AM, Claude Pache wrote: > > Almost every method found on `Function.prototype` "works" (or, at least, does > not throw a TypeError before trying to work) if and only if the target is > callable, or if and only if `typeof` applied to the target

Re: Calling toString on function proxy throws TypeError exception

2015-10-26 Thread Mark Miller
I like the idea a function proxy is more encapsulating of its implementation than a function is. I also like the idea of treating a function proxy as a builtin callable, rather than a function written in JS, and return something like "function () { [function proxy] }" as Tom suggested or

Re: Calling toString on function proxy throws TypeError exception

2015-10-23 Thread Claude Pache
Almost every method found on `Function.prototype` "works" (or, at least, does not throw a TypeError before trying to work) if and only if the target is callable, or if and only if `typeof` applied to the target produces `"function"`. That should not be different for

Re: Calling toString on function proxy throws TypeError exception

2015-10-23 Thread Tom Van Cutsem
2015-10-22 23:09 GMT+02:00 Allen Wirfs-Brock : > > > Why would it be reasonable to do this for `toString`, but not also `call`, > `apply`, and `bind`? And ultimately this problem exists for all built-in > methods that have have internal state dependencies. I just don’t see

Re: Calling toString on function proxy throws TypeError exception

2015-10-22 Thread Mark S. Miller
I know that's true in general. But we made a few exceptions, especially for functions and arrays. I thought F.p.toString was one, but maybe not. I just don't remember. On Thu, Oct 22, 2015 at 2:36 PM, Allen Wirfs-Brock wrote: > > On Oct 22, 2015, at 11:23 AM, Mark S.

Re: Calling toString on function proxy throws TypeError exception

2015-10-22 Thread Allen Wirfs-Brock
> On Oct 22, 2015, at 11:43 AM, Mark S. Miller wrote: > > I know that's true in general. But we made a few exceptions, especially for > functions and arrays. I thought F.p.toString was one, but maybe not. I just > don't remember. There are no such special cases that I’m

RE: Calling toString on function proxy throws TypeError exception

2015-10-22 Thread Brian Terlson
-discuss <es-discuss@mozilla.org> Subject: Calling toString on function proxy throws TypeError exception According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString<https://na01.safelinks.protection.outlook.com/?url=ht

Re: Calling toString on function proxy throws TypeError exception

2015-10-22 Thread Allen Wirfs-Brock
> On Oct 22, 2015, at 11:23 AM, Mark S. Miller wrote: > > Tom, this doesn't sound right to me. Didn't we intend > Function.prototype.toString to be transparent thru function proxies? > > cc'ing Allen and Brian > There is nothing unique to `toString` going on there. This

Re: Calling toString on function proxy throws TypeError exception

2015-10-22 Thread Mark Miller
Ok, that all makes sense and is fine with me. Thanks for clarifying. Tom, I'm still curious what you remember? On Thu, Oct 22, 2015 at 2:59 PM, Allen Wirfs-Brock wrote: > > On Oct 22, 2015, at 11:43 AM, Mark S. Miller wrote: > > I know that's true

Calling toString on function proxy throws TypeError exception

2015-10-22 Thread Thomas Greiner
According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString `Function.prototype.toString` is supposed to throw a `TypeError` exception when used on a function proxy. That's also consistent with how it's defined at

Re: Calling toString on function proxy throws TypeError exception

2015-10-22 Thread Tom Van Cutsem
2015-10-22 21:03 GMT+02:00 Mark Miller : > Ok, that all makes sense and is fine with me. Thanks for clarifying. > > Tom, I'm still curious what you remember? > What I remember is that the original direct proxies spec did the transparent forwarding. wiki.ecmascript.org still

Re: Calling toString on function proxy throws TypeError exception

2015-10-22 Thread Allen Wirfs-Brock
> On Oct 22, 2015, at 1:38 PM, Tom Van Cutsem wrote: > > ... > I cannot recall any specific discussions on why that behavior was changed to > throwing a TypeError instead. The only reason I can come up with is that it > could be deemed a violation of the proxy's