[pattern-switch] Opting into totality
Brian Goetz
brian.goetz at oracle.com
Mon Aug 31 23:32:35 UTC 2020
> Given that if there is a default it's already a sealed switch and that
> i can add a default to make it a sealed switch,
> i struggle to see where to use a classical statement switch and where
> to use a sealed switch ?
It feels like we're going in circles :)
One point here is that total switches are generally better _without_
default clauses, if that is semantically practical (e.g., enums, sealed
types, total type patterns) because then you don't have a catch-all that
sweeps mistakes under the rug. But the there needs to be a way to
engage totality checking / handling for statements.
Totalizing with default should not be your first move.
More information about the amber-spec-observers
mailing list