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

Guy Steele guy.steele at oracle.com
Sun Apr 10 02:45:52 UTC 2022


Nice work defining new terminology for Chapter 14.  Just a few nits:


14.11.1

A switch label is said to support a default if either it has a default label, or it has a case label with a default.

Maybe:

A switch label is said to support a default if either it has a default label, or it has a case label with a default case element.



Any variable that is used but not declared in a whenexpression must either be final or effectively final (4.12.4<https://docs.oracle.com/javase/specs/jls/se18/html/jls-4.html#jls-4.12.4>).

Make that:

Any variable that is used but not declared in a whenexpression must be either final or effectively final (4.12.4<https://docs.oracle.com/javase/specs/jls/se18/html/jls-4.html#jls-4.12.4>).




The switch block of a switch statement or a switch expression is switch compatible with the type of the selector expression, T, if all the switch labels in the switch block are switch compatible with T.

I suggest:

The switch block of a switch statement or a switch expression is switch compatible with the type of the selector expression, T, if every switch label in the switch block is switch compatible with T.

because the following sentence defines the phrase “a switch label is switch compatible with T “ rather than “(a set of) switch labels are switch compatible with T “.

(These are basic principles of the style of writing I tried to establish for JLS: (a) once you define a specific form for a technical phrase, stick as closely as possible to that form; (2) where possible, focus on a single item in preference to sets of items—this means that “every” is usually a more useful quantifier than “all”.)


[more to come? I’m too sleepy to continue reading right now]

—Guy

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


More information about the amber-spec-experts mailing list