[pattern-switch] Opting into totality

forax at univ-mlv.fr forax at univ-mlv.fr
Tue Sep 1 00:37:24 UTC 2020

----- Mail original -----
> De: "Brian Goetz" <brian.goetz at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "amber-spec-experts" <amber-spec-experts at 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 ?


More information about the amber-spec-experts mailing list