expression switch vs. procedural switch

Kevin Bourrillion kevinb at
Wed Mar 14 15:55:24 UTC 2018

On Tue, Mar 13, 2018 at 1:02 PM, Kevin Bourrillion <kevinb at>

The more I have thought about it, the more I believe that 95% of the entire
> value of expression switch is that it *isn't procedural switch*, and is
> easier to reason about than procedural switch because of all things it *can't
> *do:
>    - can't miss cases
>    - can't return
>    - can't break/continue a containing construct
>    - can't fall through
>    - (for constants or other disjoint patterns) can't depend on the order
>    of cases.
> As far as I can tell, its limitations are exactly what make it useful.

Brian reminded me in the other thread that as long as we voluntarily stick
to `->` style for all cases, we get all of this. So, from my perspective,
if we just adopt a style rule for Google Style that when using switch in an
expression context one should stick to `->`, I might have basically what I

Kevin Bourrillion | Java Librarian | Google, Inc. | kevinb at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the amber-spec-experts mailing list