final switch and straight integers

Johan Engelen via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 20 01:23:47 PDT 2016


On Wednesday, 20 April 2016 at 06:36:01 UTC, bearophile wrote:
>
> It's easy to cover all the values in a switch, using ranges.

Not as easy as you would think:
     int i;
     switch(i) {
         case 0: .. case 9:
             break;
         case 10: ..case 10000000:
             break;
         default:
             break;
     }
-->  Error: had 9999990 cases which is more than 256 cases in 
case range

The FE always lowers CaseRangeStatements into a list of 
CaseStatements, so LDC currently has the same limitation.



More information about the Digitalmars-d mailing list