----- Mail original ----- > De: "Guy Steele" <guy.ste...@oracle.com> > À: "Remi Forax" <fo...@univ-mlv.fr>, "Brian Goetz" <brian.go...@oracle.com> > Cc: "amber-spec-experts" <amber-spec-experts@openjdk.java.net> > Envoyé: Vendredi 4 Septembre 2020 04:24:24 > Objet: Re: [pattern-switch] Opting into totality
> There is currently a fundamental unpleasant asymmetry caused by the arbitrary > decision to require that all switch expressions be total but not all switch > statements be total. > > As we have added other options, the design space still has an unpleasant > asymmetry (or lack of orthogonality) because of that original decision. > > We have two choices: (a) recant that original decision, or (b) live with the > asymmetry. > > As I have already pointed out, (a) is certainly possible and completely > consistent; all you have to do is return default values for the cases that are > not covered. Then the choice of switch-versus-expression is completely > independent of the choice of regular-switch versus total-switch. The likely > result is that authors and IDEs will warn programmers that they should NEVER > EVER use a non-total switch expression, so it seems silly to expand the design > space to provide a combination of features that should never be used. (“What, > never?” “Well, hardly ever.”) > > The other choice, which is what Rémi and Brian have been discussing for the > last > week, is not whether to get rid of the asymmetry, but merely debating exactly > what its shape should be. yes > > A possibility I don;’t think I have yet seen offered is that we should, as > before, require switch expressions to be total, but also, in an incompatible > move, require switch expressions to use whatever `total-switch` syntax is > adopted. > > In such a scenario, perhaps we really are trying to move the world to `snitch` > after all, and we’re just arguing about the least disruptive spelling for it. yep, it's a snitch move, but instead of calling it "when" or whatever, we use a hyphenated keyword like "total-switch", "sealed-switch" or double words keyword like "sealed switch". I think i'm not at ease with this proposed change because it goes against the design idea that leads to the current semantics of the switch expression, the fact that a statement switch is partial while an expression switch is total. > > —Guy Rémi