dmd 1.046 and 2.031 releases

Ary Borenszweig ary at esperanto.org.ar
Mon Jul 6 11:33:50 PDT 2009


Denis Koroskin wrote:
> On Mon, 06 Jul 2009 14:12:40 +0400, Walter Bright 
> <newshound1 at digitalmars.com> wrote:
> 
>> Denis Koroskin wrote:
>>> Does it compare on case-by-case basis? Up to 256 comparisons?
>>
>> What do you mean? Obj2asm will show what it is doing.
> 
> I mean, will it translate
> 
> switch (i) {
>     case 0:
>     ..
>     case 9:
>        doSomething();
> }
> 
> into
> 
> if (i == 0 || i == 1 || i == 2 || etc) doSomething();
> 
> or into
> 
> if (i >=0 || i <= 9) doSomething();

I'm sure it translate it to:

case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:

That's obvious from the "maximum of 256 cases allowed".

And also you can see that in the source code. :)

Statement *CaseRangeStatement::semantic(Scope *sc)
...
/* This works by replacing the CaseRange with an array of Case's.
  *
  * case a: .. case b: s;
  *    =>
  * case a:
  *   [...]
  * case b:
  *   s;
  */


More information about the Digitalmars-d-announce mailing list