On Apr 27, 2021, at 9:39 AM, Brian Goetz 
<brian.go...@oracle.com<mailto:brian.go...@oracle.com>> wrote:

Where I think we need to shore up the story is in "how do I turn on 
exhaustiveness checking for statement switches.”

Yes, the non-exhaustiveness of legacy switches turns out
to be a hiding place for bugs and misconceptions.  I do like
your proposal (in the other thread) of turning on
non-exhaustiveness by default for as many switches as
possible.  It would seem to help users think about their
code more clearly.  And putting “default: break” at the
bottom seems as reasonable ask:  Basically, it annotates
that switch as non-exhaustive, making the code easier
to reason about.  In fact, *all* switches become easier
to reason about, since the last case is always the fallback.

All that said, I hope we don’t run into cases where somebody
has written a switch that really looks good w/o a default,
and will look worse with one.  Surely someone will bring
such a breed of switch, eventually, to the Big Pet Show.

— John

Reply via email to