A new function name property proposal

Brandon Benvie brandon at brandonbenvie.com
Sat Nov 17 09:45:19 PST 2012


The name property doesn't currently (and the I don't propose it should)
have a correlation to the name in scope. In function declarations the name
is only in scope because its declared in the outer scope, and this can be
overwritten permanently rendering the name unusable in that scope. A named
function expression puts the name association in a decorative scope that is
untouchable and only accessible inside the function. In ES6 two new
"function identifier modes" are introduced. For classes the same behavior
as function declarations/expressions is used but extends the scope of the
class name to all of class methods instead of just the constructor. For
methods, there is no place where the function name is in scope (technically
this existed for es5 accessors but its much more obvious/explicit for
methods when their name throws a reference error).

So given all this, the name property should definitely continue to not be
pinned to any scope record.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121117/69d00fc0/attachment.html>


More information about the es-discuss mailing list