Pattern Matching for switch (Second Preview)
Tagir Valeev
amaembo at gmail.com
Sun Sep 26 02:44:44 UTC 2021
Hello!
вс, 26 сент. 2021 г., 2:36 <forax at univ-mlv.fr>:
> >> It's not exactly the same semantics because "Object e" allows null while
> >> "default" don't.
> >
> > The semantics more more different than that; because default has special
> > prvileges with respect to ordering. Bottom line: don't use default in
> > pattern switch, use real patterns.
>
> yes very true,
> I would love to have javac to emit a warning if default is not the last
> case (for all switches).
>
Probably, it should be a compilation error for all non-legacy switches,
like we require totality for non-legacy switches? I don't think that
ability to place default in non-last case brings any profit for
programmers. It only adds confusion.
With best regards,
Tagir Valeev
More information about the amber-dev
mailing list