Functions as blocks

Allen Wirfs-Brock allen at
Wed Mar 5 18:53:53 PST 2014

On Mar 5, 2014, at 6:23 PM, Brendan Eich wrote:

> 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 bug.

We would have to come up with an an appropriate intersection semantics and we don't have a base ES semantics to work off of as a function declaration is illegal in that posiion in ES6. Would we also have to accommodate it for IterationStatements and WithStatement


More information about the es-discuss mailing list