name property for built-in functions??
brendan at mozilla.com
Wed Mar 4 15:52:06 PST 2009
On Mar 4, 2009, at 1:38 PM, Jeff Watkins wrote:
> Can I suggest that allowing writing to name may be helpful when
> creating transparent wrapper functions?
> We do a lot of this:
> function wrapWithChangeNotification(key, fn)
> return function()
> var result= fn.apply(this, arguments);
> return result;
> I'd love it if I could set the name on the new function to match the
> original function.
Why? I mean, do you expect to see that assigned name in a future
The integrity of name reflecting the declared identifier seems worth
something. Is this a case where anonymous function objects should have
no name property at all, allowing you to create one (even with high
integrity, using ES3.1's Object.defineProperty), while named function
expressions and function definitions should induce a function object
with a readonly name property?
We could certainly change Mozilla's implementations to allow name to
be written but there's a tension here between integrity and
mutability. It seems worth a bit more discussion.
More information about the Es-discuss