It’s time (actually well past time, if we hope to make the 13 train) to wrap up switch expressions. Overall, the consensus seems to be that the overall structure of the feature is correct; while some people might have preferred a different direction on the lump-vs-split choice, I don’t see any reason to change course over this. The sole issue that we wish to address has to do with how, in the case where the RHS of a -> case, we indicate the value associated with that case when it is not a simple _expression_. In the first round, we overloaded “break” to accept a value in such switches. This introduced two distortions: - Ambiguity between “break label” and “break value” where the value is a simple identifier. While the compiler is able to reason its way out of such ambiguities, we’re more concerned about the readability challenges posed to humans. - For compatibility and confusion reasons, in “breaky” constructs within the RHS of a -> case, such as a loop, you cannot break with a value through the loop to the enclosing switch _expression_. For that reason, there seems to be near-universal consensus that we choose another verb besides “break” in this context; when the keyword-resupply ship docked, the candidate of “break-with” was offered, with which people are generally OK. But, since then, I’ve had some second thoughts on this — which I’ll “break” out into a separate e-mail. If we back off to another keyword, then the first distortion goes away, and the second distortion can be corrected via the adjustments suggested by Gavin below. I believe the replacement of break with something else is the only open issue gating moving this feature forward. Unfortunately, because the spec changes are nontrivial, I think it is best that we aim for re-previewing in 13 rather than finalizing. (We have very little time left either way.) On Apr 25, 2019, at 2:11 AM, Gavin Bierman <gavin.bier...@oracle.com> wrote: |
- Revised semantics for break within switch expression Gavin Bierman
- Re: Revised semantics for break within switch expressio... John Rose
- Re: Revised semantics for break within switch expressio... Brian Goetz