digitalmars.D.learn - corner case with labled break
- BCS (17/17) Jan 25 2008 should this work? (it doesn't now)
- Jarrett Billingsley (4/21) Jan 25 2008 It's not in the grammar at all, so I'm not surprised that it doesn't. I...
- BCS (2/26) Jan 25 2008 OK, I miss phrased the question: should this be in the grammer?
- Jarrett Billingsley (4/5) Jan 25 2008 If you're proposing a feature, go ahead and propose it. I mean, I can't...
- Jason House (20/20) Jan 27 2008 Shouldn't the code be:
- BCS (35/58) Jan 27 2008 Ok, but that same problem happens with goto case #;
should this work? (it doesn't now) |void main() |{ | foo: while(true) | break foo; // works | | switch(6) | { | case 5: | while(true) | break case 5; // fails | | case 6: | goto case 5; // works | | } |}
Jan 25 2008
"BCS" <ao pathlink.com> wrote in message news:55391cb32812d8ca2d7783d0f566 news.digitalmars.com...should this work? (it doesn't now) |void main() |{ | foo: while(true) | break foo; // works | | switch(6) | { | case 5: | while(true) | break case 5; // fails | | case 6: | goto case 5; // works | | } |}It's not in the grammar at all, so I'm not surprised that it doesn't. It's a tiny feature though.
Jan 25 2008
Reply to Jarrett,"BCS" <ao pathlink.com> wrote in message news:55391cb32812d8ca2d7783d0f566 news.digitalmars.com...OK, I miss phrased the question: should this be in the grammer?should this work? (it doesn't now) |void main() |{ | foo: while(true) | break foo; // works | | switch(6) | { | case 5: | while(true) | break case 5; // fails | | case 6: | goto case 5; // works | | } |}It's not in the grammar at all, so I'm not surprised that it doesn't. It's a tiny feature though.
Jan 25 2008
"BCS" <ao pathlink.com> wrote in message news:55391cb3281338ca2d803bbfda0e news.digitalmars.com...OK, I miss phrased the question: should this be in the grammer?If you're proposing a feature, go ahead and propose it. I mean, I can't see what I'd use this for, but..
Jan 25 2008
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. 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...
Jan 27 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.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 | | } |} with break?
Jan 27 2008