corner case with labled break
BCS
ao at pathlink.com
Sun Jan 27 14:32:51 PST 2008
Reply to Jason,
> Shouldn't the code be:
>
> |void main()
> |{
> |foo: while(true)
> |break foo; // works
> |
> |bar: switch(6)
> |{
> |case 5:
> |while(true)
> |break bar; // fails
> |
> |case 6:
> |goto case 5; // works
> |
> |}
> |}
> With embedded switches, "case 5" isn't always unique.
Ok, but that same problem happens with goto case #;
based on that, this should be added:
outer: switch(n)
{
case 1:
switch(m)
{
case 2: goto outer case 2;
}
case 2:
}
> Also, the
> "break case 5" syntax almost implies to me that it should return to
> case 6. I hope that's not what you wanted...
>
Ok so it loops forever, but I /was/ intending that the break exit the loop
and continue down the case statment
This would be a more sane example.
|void main()
|{
| foo: while(true)
| break foo; // works
|
| switch(6)
| {
| case 5:
| while(true)
| break case 5; // fails
| somthing();
| break;
|
| case 6:
| goto case 5; // works
|
| }
|}
The point is that case ###: lables act like normal lables elseware, why not
with break?
More information about the Digitalmars-d-learn
mailing list