New candidate JEP: 361: Switch Expressions (Standard)

Fred Toussi fredt at users.sourceforge.net
Mon Oct 21 14:53:49 UTC 2019


Typos:

The spac still uses SwitchLabeledRule where it defines the new production.

The example with switch (day) implies we can use both the comma and the colon as case separators.

I wote to the amber-spec-observers last October (https://mail.openjdk.java.net/pipermail/amber-spec-observers/2018-October/000907.html), but got no reply to the substance of my concerns.

To avoid extensive changes to existing apps, and to reduce developer confusion with multiple colon and comma  separators (which is evident in the aforementioned mixed-up example given in the spec document) , I proposed:

1. Adding a keyword to the start of the switch _statement_ to indicate "break" will be automatic at the end of each case. I suggested "new switch(val) {",  but "switch break(va l) {" is a probably a better alternative. No change to the usage of the colon is required.

2. Continued usage of colon for switch expression cases, with the use of the proposed arrow "->" and  "yield" to return expression values. 

regards

Fred Toussi


On Mon, Oct 21, 2019, at 12:22, Gavin Bierman wrote:
> Just a gentle reminder if you have any feedback based on your 
> experience with using this feature.
> 
> Gavin
> 
> > On 27 Sep 2019, at 17:45, Gavin Bierman <gavin.bierman at oracle.com> wrote:
> > 
> > Please note that we are considering making this a permanent feature, so this is your last chance to provide substantive feedback based on any new experience you may have had with this feature.
> > 
> > A new, draft language spec for JEP 361 (Switch Expressions) is available at:
> > 
> > http://cr.openjdk.java.net/~gbierman/jep361/jep361-20190927/specs/switch-expressions-jls.html <http://cr.openjdk.java.net/~gbierman/jep305/jep305-20190918/specs/patterns-instanceof-jls.html>
> > 
> > This is identical to the version made available for JEP354, apart from some cosmetic changes around terminology following some feedback. 
> > 
> > [For spec nerds: The primary change is that what was previously called a "switch labeled rule" is now called, more simply, a "switch rule”. “Switch labeled expression” is now a “switch rule expression”, “switch labeled block” is now a “switch rule block” and a “switch labeled throw statement” is now a “switch rule throw statement”.]
> > 
> > All feedback welcomed!
> > Gavin
> > 
> >> On 25 Sep 2019, at 23:32, mark.reinhold at oracle.com <mailto:mark.reinhold at oracle.com> wrote:
> >> 
> >> https://openjdk.java.net/jeps/361 <https://openjdk.java.net/jeps/361>
> >> 
> >> - Mark
> > 
> 
>


More information about the amber-spec-observers mailing list