[Webkit-unassigned] [Bug 153909] Bound functions toString method should return "bound " + the target function's toString()

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Feb 5 14:11:37 PST 2016


https://bugs.webkit.org/show_bug.cgi?id=153909

--- Comment #1 from Saam Barati <sbarati at apple.com> ---
(In reply to comment #0)
> Via Bug 153796 [ES6] bound functions .name property should be "bound " + the
> target function's name
> 
> We improved bound functions .name, but .toString() wasn't affected.
> 
> > function foo() {return 42}
> > boundFunc = foo.bind(null)
> > boundFunc.name
> < "bound foo"
> > boundFunc.toString()
> < "function foo() {
>       [native code]
>   }"
> 
> 
> What if we return the following instead:
> 
> > boundFunc.toString()
> < "function bound foo() {return 42}"
> 
> or this:
> 
> > boundFunc.toString()
> < "bound function foo() {return 42}"
> 
> I have no preference.
> 
> Two things are different from the current behavior:
> 
> 1. Instead of "[native code]", the original content of the function is shown.
>    This is much more convenient for debugging. Currently, all anonymous
>    functions look alike:
> 
>    function () {
>        [native code]
>    }
Depending on how we do this, it's not spec compliant.
toString() needs to return a string that if eval()ed
in the original context, would reproduce an identical
function. Or, if that's not possible, the toString(),
when eval()ed, must throw a syntax error.
We could achieve a syntax error with your proposal of:
"function bound foo { return 42; }"
And I considered doing this.
But, there is new a new proposal that would require
the use of "[native code]" here:
https://raw.githubusercontent.com/michaelficarra/Function-prototype-toString-revision/fc69a0a31dc6d625736bfbb712ac782eb241ff3d/proposal.html

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20160205/c50537d4/attachment.html>


More information about the webkit-unassigned mailing list