My bad, i was thinking about the domination of the nodes in a tree of ifs, the domination in the control flow sense.
Rémi ----- Mail original ----- > De: "Brian Goetz" <[email protected]> > À: "Remi Forax" <[email protected]> > Cc: "Tagir Valeev" <[email protected]>, "amber-spec-experts" > <[email protected]> > Envoyé: Dimanche 12 Novembre 2017 18:38:47 > Objet: Re: default branch placement in switch > Agree except: the terminology of domination is backwards. Default/_ dominates > everything; most things dominate null. (Null is unordered w respect to other > constant patterns and primitive type test patterns, though). > > Sent from my MacBook Wheel > >> On Nov 11, 2017, at 11:54 PM, Remi Forax <[email protected]> wrote: >> >> I prefer default to be special and has to be at the end thus starts warning >> about default not being at the end. >> I think case null should be special too, for the same reason, case null >> dominates every cases while default dominates none. >> >> Rémi >> >> ----- Mail original ----- >>> De: "Brian Goetz" <[email protected]> >>> À: "Tagir Valeev" <[email protected]>, "amber-spec-experts" >>> <[email protected]> >>> Envoyé: Vendredi 3 Novembre 2017 22:25:18 >>> Objet: Re: default branch placement in switch >> >>> Yeah, this has to change. In existing switches, there are no case >>> labels other than default, so order is irrelevant. But now that >>> patterns have overlapping match-sets, default should be considered to >>> dominate other cases, so it should go last. >>> >>> Compatibility-wise, we have two choices for how to get there; carve out >>> a permanent exception for switches where all cases are type-restating >>> constant patterns, or plan to eventually get to a place where default >>> always comes last, even for "int" switches. If we want to get to the >>> latter, we should start warning on this construct now. >>> >>> >>> >>>> On 11/3/2017 5:10 PM, Tagir Valeev wrote: >>>> Hello! >>>> >>>> Currently the default branch can be placed in any place inside the >>>> switch operator, e.g. like this: >>>> >>>> switch(i) { >>>> case 1: System.out.println("one");break; >>>> default: System.out.println("other");break; >>>> case 2: System.out.println("two");break; >>>> } >>>> >>>> In this case behavior does not change on the order of case blocks. >>>> However in pattern matching the order of cases usually matters: if >>>> some pattern matches, this means that the subsequent patterns will not >>>> be checked. Does this mean that with pattern matching the default >>>> branch makes all the subsequent case blocks unreachable? Or default >>>> can still be located anywhere and is checked only after any other >>>> pattern? >>>> >>>> With best regards, > >>> Tagir Valeev
