Draft Spec for Third Preview of Pattern Matching for Switch and Record Patterns (JEP 405) now available

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri Apr 8 10:57:26 UTC 2022


Hi Gavin,
great work - some comments:

* in section 6 on names there's no mention of whether pattern variables 
are matched in the `when` clause.

* section 14.11.1, you say that a case element is "unrefined" if it has 
`when` with constant expression whose value is `true`. This is a bit 
ambiguous: I think what you want here is "evaluates to true", because I 
think you also want to cover "true || true" or "!!true", right? I think 
that's what you meant, but the word "value" is confusing, I think. This 
ambiguity is also present in the rule below when we say that two case 
label with same "value" are not permitted. Maybe all this is 
pre-existing, but I wonder it it could be worth clarifying.

* we define the concept of what it means for a case label to "support 
default" but we do not define what it means to "support null". The 
latter is also referred to in the list of checks for switch labels in 
14.11.1

* "If a switch label appears at the end of a switch block, it is a 
compile-time error if it consists of more than one case or default 
label." - not sure I get this? I mean, sure I can't have "case default: 
case default" - but the rest? E.g. can't I end a switch with "case 4: 
case 5: ..." ?

* this sentence "A switch label that supports a unrefined pattern p 
dominates another switch label supporting a pattern q if p dominates q" 
is tricky - but I think correct; only labels w/o a "when" can dominate 
other labels, and pattern dominance doesn't care about "when", so you 
shold be good.

* 10.3.2 and also the small example at the end of the definition of 
"executable switch" refer to the notion of "any" pattern - but that 
pattern is not defined

Maurizio



On 07/04/2022 12:40, Gavin Bierman wrote:
> Dear experts:
>
> The first draft of a spec covering both the third preview of Pattern 
> Matching for switch (JEP number coming, but currently available at 
> https://openjdk.java.net/jeps/8282272) and JEP 405 (Record Patterns) 
> is now available at:
>
> http://cr.openjdk.java.net/~gbierman/PatternSwitchPlusRecordPatterns/PatternSwitchPlusRecordPatterns-20220407/specs/patterns-switch-jls.html 
>
>
> Comments welcome!
>
> Thanks,
> Gavin 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20220408/2c8434a4/attachment.htm>


More information about the amber-spec-experts mailing list