Break in switch inside loop [was Re: Loop iterator - example.txt]

James Dunne james.jdunne at gmail.com
Sun Apr 30 10:58:27 PDT 2006


Unknown W. Brackets wrote:
> [snip]
> 
> int pos = 0;
> while (pos < string.length)
> {
>     switch (string[pos])
>     {
>     case something:
>         pos += some_other_function(string[pos .. string.length]);
>         break;
> 
>     case something_else:
>         pos += some_other_function2(string[pos .. string.length]);
>         break;
> 
>     default:
>         pos++;
>     }
> }
> 

Does anyone else see the inconsistency with the break and continue 
keywords as applied to switch statements within loop constructs?

switch uses break to leave the switch statement, while continue is still 
used in the loop context.  I think this should be fixed so that exit 
leaves the switch statement and break and continue are left for the loop.

-- 
Regards,
James Dunne



More information about the Digitalmars-d mailing list