No more fall through in case statement?

Bruce Adams tortoise_74 at yeah.who.co.uk
Sat Jan 5 14:48:01 PST 2008


On Sat, 05 Jan 2008 11:50:33 -0000, Janice Caron <caron800 at googlemail.com>  
wrote:

> On 1/5/08, BC <notmi_emayl_adreznot at hotmail.com.remove.not> wrote:
>> > The way I see it, the advantage of "switch/case" over "if" is that the
>> > compiler might be able to find cool ways to optimize the code (e.g
>> > binary search, sparse array lookup, table lookup, whatever). If the
>> > compiler can't do that, well then, what's the point of using it at all
>> > when "if" is perfectly expressive already?
>>
>> Do you know if the compilers actually do this?
>
> Me? Hell no! I don't write compilers. But Walter may be able to answer
> that question for D.
>
> I do know the answer for at least one ancient compiler of old. I know
> that back in the days of AmigaDOS, the Amiga compiler used a choice of
> two strategies. It would create a simple O(1) lookup table if all the
> values were contiguous, or nearly contiguous, or an O(log(N)) binary
> search otherwise. But that was then and this is now and things are
> bound to be different.

SAS C++? them were the days...



More information about the Digitalmars-d mailing list