[Issue 5714] case ranges in final switches
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Dec 2 05:56:00 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5714
Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |andrej.mitrovich at gmail.com
--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-12-02 05:55:57 PST ---
(In reply to comment #0)
> If case ranges are not allowed on full-range int values, then you can't use
> them in a final switch.
Basically the compiler just translates this:
case 1: .. case 3: call()
into:
case 1:
case 2:
case 3:
call()
And it also limits the number of cases to 256 (for optimization purposes?).
So a final switch would only work on byte-types. I'm not sure if Walter would
like a feature that only works with one fundamental type. Note also that
because `final switch` currently works on ints (personally I would reject such
code), people would assume they could add case ranges for the full int type,
but they would get the 256 case limitation error instead.
As a current workaround you could use a mixin that generates the case
statements and a 'default' which throws a SwitchError.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list