<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Bound functions toString method should return "bound " + the target function's toString()"
href="https://bugs.webkit.org/show_bug.cgi?id=153909#c1">Comment # 1</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Bound functions toString method should return "bound " + the target function's toString()"
href="https://bugs.webkit.org/show_bug.cgi?id=153909">bug 153909</a>
from <span class="vcard"><a class="email" href="mailto:sbarati@apple.com" title="Saam Barati <sbarati@apple.com>"> <span class="fn">Saam Barati</span></a>
</span></b>
<pre>(In reply to <a href="show_bug.cgi?id=153909#c0">comment #0</a>)
<span class="quote">> Via <a class="bz_bug_link
bz_status_REOPENED "
title="REOPENED - [ES6] bound functions .name property should be "bound " + the target function's name"
href="show_bug.cgi?id=153796">Bug 153796</a> [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]
> }</span >
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:
<a href="https://raw.githubusercontent.com/michaelficarra/Function-prototype-toString-revision/fc69a0a31dc6d625736bfbb712ac782eb241ff3d/proposal.html">https://raw.githubusercontent.com/michaelficarra/Function-prototype-toString-revision/fc69a0a31dc6d625736bfbb712ac782eb241ff3d/proposal.html</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>