Switch expression fall through

Brian Goetz brian.goetz at oracle.com
Wed Mar 14 01:16:25 UTC 2018

Expression switches and statement switches are the same construct.  There are some mild differences around the edges (i.e., one returns a value, the other does not), but they are one construct.  I get that you hate fall through, but we can’t rid ourselves of fall through (we’ll still have switch statements), and having two subtly different switch constructs is even worse.  Java’s switch construct, for better or worse, has fall through.  

(And, by the way, there’s nothing wrong with fall through.  The mistake is _fallthrough by default_.  Fall through itself is perfectly reasonable; its just that the default is wrong.  Like so many others.)  

But, I’m repeating stuff you could just as well have read on amber-spec-experts, so I’ll stop here.  

> On Mar 13, 2018, at 7:15 PM, Stephen Colebourne <scolebourne at joda.org> wrote:
> A recent email to amber-spec implies that expression switch will
> support fall-through.
> http://mail.openjdk.java.net/pipermail/amber-spec-experts/2018-March/000332.html
> Is this true? If so, on what basis is this justified?
> (Fall through in switch is the spawn of the devil. Allowing it in the
> brand new expression switch would be horrific IMO.)
> Stephen

More information about the amber-dev mailing list