"Pretty" function expression names

Brendan Eich brendan at mozilla.com
Sun May 10 15:41:11 PDT 2009

On May 10, 2009, at 2:25 PM, Laurens Holst wrote:

> Laurens Holst schreef:
>> Brendan Eich schreef:
>>> http://wiki.ecmascript.org/doku.php?id=strawman:name_property_of_functions
>>> I did not reproduce all the details from the thread, but I tried  
>>> to capture the essential points. Please point out omissions and  
>>> errors. Thanks,
>> What I’m missing about Function.name is that you can only specify  
>> it using function literals (at least, currently in Firefox I think  
>> that is the case). It would be nice if you could also either set  
>> this with either the Function constructor, or after the object has  
>> been created.
> Ah, I see this part is already covered by Maciej’s Function.create  
> semi-constructor proposal. In that case, should make sure this  
> Function.create also supports passing closures so that we won’t need  
> a Function.create2 :).

Why would we ever want to mutate a closure? Please re-read


> Maybe make the params parameter list an array so that create is less  
> dependant on the length of the arguments passed and more extensible.

This sounds like a good idea to me. The counter-argument is the  
obligatory overhead of an array of parameter names. Others should  
weigh in.

One good thing about your proposal: it avoids (or fails to reuse, on  
the down side) quirky standard behavior of the Function constructor.  
Did you know ES1 specifies that new Function("a,b", "a+b") creates a  
function similar to function anonymous(a, b) { return a + b; }? That  
string-pasting feature of the Function constructor would seem to carry  
over to Function.create, at first glance.


More information about the es-discuss mailing list