What is the use case for this weird switch mecanism

deadalnix deadalnix at gmail.com
Tue Oct 30 13:39:06 PDT 2012


Le 30/10/2012 18:47, Philippe Sigaud a écrit :
>>> What the hell statement is supposed to do ? And what is the use case
>>> for this ?
>>
>> That's weird. I just did a quick test; apparently statement is never
>> run. I've no idea why it's allowed or what it's for.
>
> I've no idea why it's authorized, but it saved my day a week ago, in
> an automatically-generated switch statement that happened to have a
> "return true;" inserted at the very beginning. No unit test found that
> and I saw it only by printing the generated code for another search.
>
> In a way, it's logical: the code path jumps to the matching case, so
> it never sees the first statement block before the first case.

I usually want to avoid code working in an unexpected way. Even when it 
make code work when I expect it shouldn't.

I wrote about this publicly few mounth ago, and, considering how much 
return I got, I'm not the only one.


More information about the Digitalmars-d mailing list