----- Mail original ----- > De: "Brian Goetz" <brian.go...@oracle.com> > À: "Remi Forax" <fo...@univ-mlv.fr> > Cc: "amber-spec-experts" <amber-spec-experts@openjdk.java.net> > Envoyé: Mardi 1 Septembre 2020 01:32:35 > Objet: Re: [pattern-switch] Opting into totality
>> 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. In that case, what's the point of allowing default ? And you did not really answer to my question, when should i should prefer one to the other ? Rémi