> On Apr 27, 2018, at 11:03 AM, Gavin Bierman <gavin.bier...@oracle.com> wrote:
> 
> I have uploaded the latest draft of the spec for JEP 325 at 
> http://cr.openjdk.java.net/~gbierman/switch-expressions.html
> 
> Changes from the last version:
> * Supports new -> label form in both switch expressions and switch statements
> * Added typing rules for switch expression
> * Restrict the type of a selector expression to not include long, double and 
> float as previously proposed
> * Misc smaller changes from community feedback (thanks!)
> 
> Comments welcomed!

Note the (certainly currently intentional) lack of structural parallelism in 
these two parts of the BNF in Section 4.11:
__________________________________

SwitchStatementClause:

        ClauseLabel Statement

ClauseLabel:

        CasePattern ->
__________________________________

SwitchBlockStatementGroup:

        GroupLabels BlockStatements

GroupLabels:

        GroupLabel {GroupLabel}

GroupLabel:

        CasePattern :
__________________________________

They can easily be made structurally parallel by changing the first two cited 
rules to:
__________________________________

SwitchStatementClause:

        ClauseLabels Statement

ClauseLabels:

        ClauseLabel {ClauseLabel}

ClauseLabel:

        CasePattern ->
__________________________________

which of course results in precisely my earlier proposal to allow multiple 
clause labels on a single statement—this note is merely to point out that it is 
an easy and unsurprising change to the BNF.

Then in Section 15.29 one need only change
__________________________________

SwitchExpressionClause:

        ClauseLabel Expression ;
        ClauseLabel Block
        ClauseLabel ThrowStatement
__________________________________

to
__________________________________

SwitchExpressionClause:

        ClauseLabels Expression ;
        ClauseLabels Block
        ClauseLabels ThrowStatement
__________________________________

“It’s not fallthrough—it’s multiple labels.”

—Guy



Reply via email to