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

Guy Steele guy.steele at oracle.com
Fri Apr 8 02:23:03 UTC 2022



On Apr 7, 2022, at 7:40 AM, Gavin Bierman <gavin.bierman at oracle.com<mailto:gavin.bierman at oracle.com>> 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

Also missing Oxford comma in first bullet of 6.3.2.6 switch Statements.

6.3.3.2 Record Pattern

The following rule applies to a record pattern p:

  *   For each pattern q in the record component pattern list of p, a pattern variable declared by q is definitely matched in the rest of record component pattern list.

It is a compile-time error if a pattern variable declared by q is already in scope somewhere in the rest of the record component pattern list.

Is the term “rest of the list” carefully defined elsewhere? Otherwise it could be misconstrued as “anywhere else in the list.

Perhaps:

• For each pattern q in the record component pattern list of p, a pattern variable declared by q is definitely matched in every record pattern component that comes after it within the list.

or

• For each pattern q in the record component pattern list of p, a pattern variable declared by q is definitely matched in every record pattern component that is to its right within the list.

and similarly for the next sentence (“It is a compile-time error . . .”).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20220408/486bd994/attachment.htm>


More information about the amber-spec-experts mailing list