"Pretty" function expression names

Laurens Holst laurens.nospam at grauw.nl
Sun May 10 14:18:16 PDT 2009

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.

This is functionality that is currently missing, so that function 
constructors are second-class citizens compared to function literals. 
(By the way, while you’re at it, it would be nice if the constructor 
also allowed closures to be specified, because that is also something 
functions created with the Function constructor unfortunately cannot do).

Also, it would be nice if when a function is declared as follows:

yyy.xxx = function() { … }

yyy = { xxx: function() { … } }

That in both these cases the function’s name property would be ‘xxx’ as 

Both these would aid debuggability of functions. Currently we have code 
that looks like this to aid stack trace debugging:

xx.core.Events.createEvent = function xx_core_Events_createEvent() { … }

This makes the function show up with the name 
‘xx_core_Events_createEvent()’ instead of ‘anonymous()’ in Firebug, 
which I guess is an improvement, but I think this is a terribly ugly way 
to go about it :). So it would be nice if I could just leave the name 
out and it would still show up as ‘createEvent()’ (I can make do without 
the xx.core.Events part).


Note: New email address! Please update your address book.

~~ Ushiko-san! Kimi wa doushite, Ushiko-san nan da!! ~~
Laurens Holst, student, Utrecht University, the Netherlands
Website: www.grauw.nl. Backbase employee; www.backbase.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: laurens_nospam.vcf
Type: text/x-vcard
Size: 111 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20090510/f1077335/attachment.vcf>

More information about the es-discuss mailing list