final switch and straight integers

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 21 05:47:08 PDT 2016


On 4/20/16 4:23 AM, Johan Engelen wrote:
> 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.
>

Um... this seems a horrid limitation.

-Steve


More information about the Digitalmars-d mailing list