On Sep 17, 2009, at 11:52 PM, Garrett Smith wrote:

ES5 Committee,

In Function.prototype.toString, the representation should be a
"Function Definition". The current text requires a
"FunctionDeclaration". Many (if not most) implementations today, do
not follow the standard in the following cases:

1) anonymous function
2) native code

Example:-
javascript: alert([parseInt, function(){}].join('\n\n'));

Many browsers produce a result something like:
function parseInt() {
   [native code]
}

function () {
}

An implementation could probably change the first to produce a result such as:-

function () { /* [native code] */ }

That should be harmless, and wacky scripts that try to parse [native
code] could continue to do so without breaking.

For an anonymous function, an implementation could produce:-

function anonymous(){}

But that would be a bit odd, as the function does not have the
identifier "anonymous".

The specification should allow FunctionExpression, so that:-

function(){}

Alas these changes would break things -- In JSC we have had many bug reports due about site breakage, which ended up being due to slight changes in in the formatting of function [[ToString]] conversion. Any changes to it are immensely risky (we've had at least a couple of bugs that were due to specific spaces and newlines not being in the "right" place), the degree of changes you're asking for are almost certain to break sites.

--Oliver
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to