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

Gavin Bierman gavin.bierman at oracle.com
Wed Apr 20 15:51:24 UTC 2022


Thanks for spotting these, Guy. All corrected.

Gavin

On 10 Apr 2022, at 03:45, Guy Steele <guy.steele at oracle.com<mailto:guy.steele at oracle.com>> wrote:

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/20220420/7e20ef1d/attachment-0001.htm>


More information about the amber-spec-experts mailing list