On Jun 2, 2022, at 2:22 PM, Dan Smith 
<daniel.sm...@oracle.com<mailto:daniel.sm...@oracle.com>> wrote:

Ideally, the fallthrough rule should be about _bindings_, not _patterns_. If P 
an Q are patterns with no binding variables, then it should be OK to say:

case P:
case Q:

The rule about fallthrough is to prevent falling into code where the bindings 
are not DA.

Yes, understood.

The current explanation doesn't actually treat this as fallthrough, though: it 
treats it as if you said 'case 23, Pattern:', which is disallowed by a 
different rule.

Oh, I guess I missed your point here, thinking that P and Q were constants.

Your comment implies that the two rules that restrict usage of patterns—can't 
fall through past one, and can't combine one (via ',') with most other 
labels—could be relaxed slightly in the case of patterns that have no bindings. 
I suppose that's formally true, though I'm not sure it's practically all that 
useful. (The only non-binding pattern we have right now is a zero-component 
record, right? And any non-binding patterns in the future could be equivalently 
expressed with 'when' clauses.)

This is an orthogonal point to my suggestion that sets of switch block labels 
not be merged; it is relevant, however, to my suggestion that Patterns be 
syntactically impossible to combine (via ',') with most other labels.

Reply via email to