On Nov 11, 2011, at 10:22 AM, gaz Heyes wrote:

> On 11 November 2011 17:13, David Herman <dher...@mozilla.com> wrote:
> Your idea of mandatory parens is still valid (if, IMO, a bit unsatisfyingly 
> verbose) for most statement forms. It's only the block-statement-expression 
> that doesn't work. Hence my do-expressions
> 
> It should also apply to function expressions IMO too as there are instances 
> especially in for loops where there is confusion between the two.

We are not going to make parens around function expressions mandatory -- gaz, 
is that what you meant?

Mark's idea need not mandate parens. We can make all statements that start with 
keywords be AssignmentExpression right parts, *and* extend the lookahead 
restriction under ExpressionStatement to forbid all those keywords. Then you'd 
have to parenthesize most of the time, but not in actual parameter lists, 
initialiser lists, or comma expressions.

The other problem, the lack of ASI one, is an incompatibility, but it may be 
tolerable:

let x = switch (y) {case 1:...default:...}
(why_am_i_overparenthesized ? no_idea : maybe_because)(42);

This can't work in old browsers, and in new ones it would not trigger ASI, 
rather chained calls of whatever callee the switch evaluates to.

Requiring parens around the switch in an example like this may or may not help. 
Yes, today

let x = (parenthesized_for_some_reason())
(why_am_i_overparenthesized ? no_idea : maybe_because)(42);

is a known lack-of-ASI hazard in the language (imagine many newlines and even 
comments between the two lines). We can fix it only by making newlines *more* 
significant, note well.

But if we allow keyword-statements to be assignment expressions, parens are no 
guarantee that someone used ; where they should have.

/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to