name property for built-in functions??

Maciej Stachowiak mjs at apple.com
Thu Mar 5 17:31:32 PST 2009


On Mar 3, 2009, at 8:01 PM, Mark S. Miller wrote:

> I like most of what you just proposed, except that I find it  
> surprising that a function's ".name" is not the identifier used by  
> ".toString()" on that function. This same issue just came up on an  
> internal list at Google: Objecting that since ES3.1 specs that the  
> ".name" for bound functions and literal getters and setters is not  
> an identifier, it would break .toString() if it were used in the  
> identifier position of a function's .toString().
>
> On Tue, Mar 3, 2009 at 7:35 PM, Allen Wirfs-Brock <Allen.Wirfs-Brock at microsoft.com 
> > wrote:
> A quick post-script.  We could also give Function.prototype.name a  
> different name, perhaps "identifier" if we don't want to trample  
> over the existing FF and Chrome implementations.  Too bad "name" is  
> such a good name for this functionality.
>
> The other way to reconcile this is to retreat to keeping the name  
> "name", but having it always agree with the identifier used the  
> function's .toString(). If we do this, then we should choose a good  
> enough identifier mangling scheme for bound functions  
> ("bind_<original-ident>") and literal getters and setters  
> ("get_<ident>", "set_<ident>"), and use it in both the .name and in  
> the identifier position of .toString(). Ugly as this is, I think  
> it's better than having two different names associated with the same  
> function by two different parts of our API merely because we  
> couldn't agree on one.

This position makes sense to me. Although I don't think it is a hard  
requirement for the name to match the identifier used in the  
toString() serialization, I think it is simpler and more consistent to  
do it this way.

  - Maciej

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


More information about the Es-discuss mailing list