evaling anonymous function declarations

Brendan Eich brendan at mozilla.org
Fri Jun 12 18:34:59 PDT 2009


On Jun 12, 2009, at 4:49 PM, Allen Wirfs-Brock wrote:

> Basically, the anonymous function declaration issue is about whether  
> or not eval(“function () {};”); should return a function object or  
> produce a syntax error although the suggested fix would also make  
> such anonymous function declaration syntactically legal outside of  
> evals.
>
> Cursory testing suggests that Opera and Chrome return the function;  
> that FF, and Safari throw a syntax error; and, that IE returns  
> undefined.

Firefox 2 and older SpiderMonkey-based browsers allowed this, it goes  
back to the dawn of time. For Firefox 3 beta releases we tried fixing  
things so per ES3, function(){} as a Program is invalid syntax. We  
seem to have got away with it, as the extension no longer works in  
Firefox 3 and 3.5.


> Technically, this is “new syntax” (if we do this there will be valid  
> ES5 programs that cause syntax errors on ES3 implementations) and it  
> doesn’t  meet the 3 out of 4 (or 5) guideline we’ve applied in the  
> past.

4 (not 5, while V8 is slaved to JSCore).

Thanks for testing, I had forgotten about our bold attempt to break  
this old extension and comply with ES3. Unless this is about to be  
fixed in WebKit, I agree we can stand on ES3 precedent.

/be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es5-discuss/attachments/20090612/d9c44a50/attachment.html>


More information about the es5-discuss mailing list