Re: Simplifying switch labels

2022-06-03 Thread Brian Goetz
I wonder how we would try to explain 'case Integer x, null, Double x'... (Does 'x' get bound to 'null'? How?) Your suggestion to always put the null first probably helps.

Re: Simplifying switch labels

2022-06-02 Thread Dan Smith
> On Jun 2, 2022, at 2:59 PM, Brian Goetz wrote: > > >> 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

Re: Simplifying switch labels

2022-06-02 Thread Brian Goetz
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 hav

Re: Simplifying switch labels

2022-06-02 Thread Dan Smith
On Jun 2, 2022, at 2:22 PM, Dan Smith 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 fallin

Re: Simplifying switch labels

2022-06-02 Thread Dan Smith
> On Jun 2, 2022, at 12:08 PM, Brian Goetz wrote: > >> In this framing, the restrictions about sets of elements in a single label >> don't apply, because we're talking about two different labels. But we have >> rules to prevent various abuses. Examples: >> >> case 23: case Pattern: // illegal

Re: Simplifying switch labels

2022-06-02 Thread Remi Forax
- Original Message - > From: "Brian Goetz" > To: "daniel smith" , "amber-spec-experts" > > Sent: Thursday, June 2, 2022 8:08:14 PM > Subject: Re: Simplifying switch labels >> In this framing, the restrictions about sets of elements

Re: Simplifying switch labels

2022-06-02 Thread Brian Goetz
In this framing, the restrictions about sets of elements in a single label don't apply, because we're talking about two different labels. But we have rules to prevent various abuses. Examples: case 23: case Pattern: // illegal before and now, due to fallthrough Pattern rule Ideally, the

Simplifying switch labels

2022-06-01 Thread Dan Smith
I recently reviewed the spec changes for patterns in switch, and found the treatment of switch labels pretty hard to work out. Since this is really about the design more than the specification, I thought I'd share some thoughts here. Consider this early feedback on the Java 19 preview. The stat