name property for built-in functions??

Brendan Eich brendan at mozilla.com
Sat Feb 28 21:59:43 PST 2009


There is long-standing precedent for the plain identifier:

js> Array.prototype.toString.name
toString

What should (new Function).name or (equivalently) Function().name  
return? Precedent in some engines:

js> (new Function).name
anonymous

An anonymous function expression returns the empty string in some  
implementations:

js> (function(){}).name

js> typeof (function(){}).name
string
js> (function(){}).name.length
0

/be

(Is "printString" a VB-ism? ;-)

On Feb 28, 2009, at 6:31 PM, Allen Wirfs-Brock wrote:

> Because we have introduced a “name” property for function objects we  
> have to specify what values the built-in functions in Section 15  
> each have for this property.  Note that the value of this property  
> is intended to be a descriptive name and is not necessarily a simple  
> identifier.  We have already taken advantage of this in specify the  
> “name” of functions created using Function.prototype.bind.
>
> So what should name property values  be for a built-in function such  
> as Array.prototype.printString?  The straight forward thing to do is  
> to say it is “printString”.  However, it would be potentially more  
> useful for debugging purposes if it was “Array.prototype.printString”.
>
> Thoughts?  I’m probably going to specify that simple identifier  
> unless I hear a strong response in favor of using the fully  
> qualified name.
>
> Allen
> _______________________________________________
> Es-discuss mailing list
> Es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20090228/46861361/attachment.html>


More information about the Es-discuss mailing list