Stephen reharsh what Cay Horstmann said two years ago :(

The main issue is that there is still a lot of switch on string/characters that 
are using fallthrough for a good reason.
You can put your blinkers and pretend that those switches never exist, that 
falltrough is the root of all evil and that nobody will want to refactor them 
to be switch expression, it's not what the EG group has decided.

We, several Google guys in fact, have done some research on the existing 
switches, if i remember correctly the conclusion were:
- there are very few switches per libraries, so the stats are not that useful 
because we expect more usages in the future,
- most of the switches has one of the case that have more than one statement, 
so the syntax has to mix only one line case with multi-lines cases
- there very very few switches with default not at the end
- switch are used a lot for string/characters parsing, think a lexer, and those 
are using fallthrough (the intended use case of the switch in C)

The last point explain why we ends up with a 2x2 matrix.
Obviously, you may argue that the first point make the matrix useless because 
in the future all switches will be only pattern matching switches so in term of 
percents the number of switches used on strings + fallthrough will be 
negligible.
 
Rémi

----- Mail original -----
> De: "Daniel.Sun" <sun...@apache.org>
> À: "dev" <d...@groovy.incubator.apache.org>
> Envoyé: Mardi 5 Novembre 2019 05:21:16
> Objet: Re: [VOTE] Support switch expression in the next version

> It does not matter. Different people have different concerns.
> 
> Maybe we could do better if time allowed:
> https://blog.joda.org/2019/11/java-switch-4-wrongs-dont-make-right.html
> 
>> and Happy Birthday from me, whenever the exact date is G-)
> 
> Thank you, MG :-)
> 
> Cheers,
> Daniel.Sun
> 
> 
> 
> 
> -----
> Apache Groovy committer & PMC member
> Blog: http://blog.sunlan.me
> Twitter: @daniel_sun
> 
> --
> Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html

Reply via email to