About switch case statements...

Ellery Newcomer ellery-newcomer at utulsa.edu
Sun Nov 15 14:51:57 PST 2009


Andrei Alexandrescu wrote:
> Walter Bright wrote:
>> Don wrote:
>>> And looking at how rarely it's actually used by someone who thinks he
>>> uses it a lot, convinces me that intentional use of fall-through is
>>> much less common than bugs introduced by leaving out a break statement.
>>
>> Except that I cannot recall ever having a bug from leaving out a break
>> <g>.
> 
> I can. I'm not sure where that leaves us. Others - please add your
> experience.
> 
> Andrei

Just did a quick scan of phobos1. Found 5 instances of fallthrough, not
including one around line 182, format.d

    case Mangle.Tdchar:
      ti = typeid(dchar);
    default:
      ti = null;

I have a hard time believing that was intentional, although it as near
as I can tell it will never be executed.

"Written by Walter Bright"

hm.




More information about the Digitalmars-d mailing list