Functions as blocks

Brendan Eich brendan at mozilla.com
Wed Mar 5 18:23:10 PST 2014


John Barton wrote:
> As you say "all browsers seem to allow it". Browsers made the mistake 
> and we should not go back now and blame developers on smaller sites 
> because they use this kind of code. Make it a syntax error in modules 
> and save yourself a lot of headaches.

We could do this for sure, and in the absence of evidence that if (x) 
function y(){} is used in the wild, we should. With such evidence, we 
should. So, we should ;-).

But there's more to consider. IIRC, originally KJS (pre-JSC) in WebKit 
did not support function-in-block or function-in-unbraced-consequent. 
Then they added function-in-block support, bowing to the well-known uses 
on the Web. When did they add function-in-unbraced, and why? Perhaps 
someone can cite the fixed webkit.org bug.

/be


More information about the es-discuss mailing list