return when desugaring to closures

Brendan Eich brendan at mozilla.com
Mon Oct 13 15:25:15 PDT 2008


On Oct 12, 2008, at 9:34 PM, Mark S. Miller wrote:

> On Sun, Oct 12, 2008 at 7:55 PM, David-Sarah Hopwood
> <david.hopwood at industrial-designers.co.uk> wrote:
>> In ES3.1, this will mean that they normally require braces whenever a
>> body can introduce variables. There are two classes of exceptions,
>> shown by these examples:
>>
>> a) while (...) foo: var x = ...;
>> b) while (...) for (var x = ...; ...; ...) {}
>>
>> I think these are bugs. a) can certainly be disallowed. There might
>> possibly be existing code that is relying on b), confusing though it
>> is, but it can be disallowed in strict mode at least.
>
> ES3.1 will disallow #a because a LabelledStatement can only contain a
> SubStatement. A variable declaration is a Statement but not a
> SubStatement.
>
> Your point about #b is interesting. I do not know if it has previously
> been raised.

Why is it interesting?

We allow var in for heads, no matter how nested. This has been in the  
spec since the first edition. It is not a bug. We should not break it  
in strict mode.

/be



More information about the Es-discuss mailing list