On Wednesday, 20 April 2016 at 17:42:03 UTC, Basile Burg wrote:
On Wednesday, 20 April 2016 at 10:19:17 UTC, Dominikus Dittes Scherkl wrote:

Anyway, something need to be changed.
a) allow Range Cases (nice for ints but bad idea for enums)
b) require also non-enum types to explicitly state all cases (bad idea for any multi-byte type, even near useless for single bytes)
c) forbid other types than enum in final switch

I strongly vote for (c).

A good `int` value for a variable `int x` can be enforced (min(), max(), clamping, warping, etc) **before** a final switch(x).
No, because final switch requires you to enumerate all possible cases.
If c) is done then the compiler in this cas would disallow something that's completly safe (generally speaking I mean, here safe == no SwitchException possible).
Why would you ever want to use final switch on int? Why not simply use the normal switch? Especially if you enforced a useful range with min(), max(), etc. would it not be better to do the remaining cases manually? (or even do the range check in the default case?)

Reply via email to