Switch-case made less buggy, now with PATCH!

Don nospam at nospam.com
Sat Nov 21 00:22:54 PST 2009


Chad J wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=3536
> 
> So Walter, with this you can keep your beloved fall-through.
> Now can the rest of us be spared the nasty fall-through bugs, please
> please please??
> 
> Also, about assert(0)... I'd be happy to change what I did if Walter and
> associates feel that adding assert(0) to the list is worth its minor
> complications.
> 
> (Sorry I don't have a patch for properties, but that one's harder.)
> 
> - Chad

Things like

case A:
case B:
       foo();
       break;

do not involve fallthrough bugs. If there's a bug in that code at all, 
it's that case A doesn't do anything. Empty case statements are not 
bug-prone.

The thing is, that with the "goto case" syntax, D already has support 
for explicit fallthrough. No new syntax is required.

BTW accidental fallthrough can be detected in the parse step, no 
semantic analysis is required, which makes it particularly easy to 
implement in a lint tool.



More information about the Digitalmars-d mailing list