return when desugaring to closures

David-Sarah Hopwood david.hopwood at
Sun Oct 12 17:34:07 PDT 2008

Mark S. Miller wrote:
> On Sun, Oct 12, 2008 at 2:19 PM, Yuh-Ruey Chen <maian330 at> wrote:
>> David-Sarah Hopwood wrote:
>>>   { while (...) let x = ...; }
>> I was under the impression that such statements should be disallowed,
>> following the example of JS1.8. In JS1.8 (Fx3), the following are all
>> syntax errors:
>> while (...) let x = ...;
>> do let x = ...; while (...);
>> if (...) let x = ...;
>> for (...) let x = ...;
> These are unconditionally disallowed starting in ES3.1 because such
> declarations are Statements but not SubStatements and only
> SubStatements are allowed by the grammar at the positions above.

Excellent. (I had thought these were only disallowed in strict mode,
based on MarkM's comment at
but disallowing them unconditionally is even better IMHO.)

So why are we arguing about whether lambdas should be allowed without
braces, when the direction being taken for the rest of the language
is to make the braces mandatory around all forms that can potentially
declare variables?

David-Sarah Hopwood

More information about the Es-discuss mailing list