> On May 10, 2018, at 4:54 PM, Brian Goetz <[email protected]> wrote:
>
>> * It would feel strange to even bother applying this exhaustiveness goo to
>> byte switches. If we ever had ranges.... of course then, any type of switch
>> could join the party. (I don't know whether ranges are a thing we're
>> considering or not and I'm not pushing that we do.)
>
> Yeah, its on the edge. Its a no-brainer for `boolean`, its nuts for `int`
> (without ranges), but its vaguely defensible for `byte`. Though I can't
> really get too excited about it.
The choice is not just among four sizes of integer. One could imagine
recognizing certain idioms such as
switch (myInt & 7) {
case 2, 3, 5, 7 -> “prime”;
case 0, 1, 4 -> “square”;
case 6 -> “perfect”;
}
and understanding that they are exhaustive. Dunno if the compiler guys want to
go there.
—Guy