D - break from labed statement.
- Mike Wynn (17/17) Aug 21 2003 to continue (a little) the old goto debate,
- Sean L. Palmer (11/28) Aug 21 2003 Named break and goto are effectively the same thing, right? Labels atta...
- Philippe Mori (13/43) Aug 21 2003 labels
- Mike Wynn (11/52) Aug 21 2003 attach
- Philippe Mori (44/97) Aug 21 2003 exactly
- Sean L. Palmer (4/43) Aug 22 2003 That's certainly interesting!
- Sean L. Palmer (14/33) Aug 22 2003 from
- Mike Wynn (8/34) Aug 22 2003 not a great deal, only that 'goto' contains no implicit direction
- Vathix (8/25) Aug 21 2003 I think it'd be better called "break from block to label's scope". If yo...
to continue (a little) the old goto debate, one of the uses of goto is to get to the end of a block from an if without writing a 1000 nexted if else's ........ I'd like to be able to write done:{ .... if (...) { if ( ... ) { break done; } } } instead of writing done:do{ .... if (...) { if ( ... ) { break done; } } } while( false );
Aug 21 2003
Named break and goto are effectively the same thing, right? Labels attach to the beginning or end of their block? I'd rather them attach exactly at the point of flow where the label is encountered, so you can put the label either before or after a block. Simpler than trying to identify the labels with a loop or block. Maybe if we removed the goto keyword while in the meantime extending the power of the named break to effectively replace it... it would satiate the whiners, a little bit. ;) Sean "Mike Wynn" <mike.wynn l8night.co.uk> wrote in message news:bi1t45$227t$1 digitaldaemon.com...to continue (a little) the old goto debate, one of the uses of goto is to get to the end of a block from an if without writing a 1000 nexted if else's ........ I'd like to be able to write done:{ .... if (...) { if ( ... ) { break done; } } } instead of writing done:do{ .... if (...) { if ( ... ) { break done; } } } while( false );
Aug 21 2003
"Sean L. Palmer" <palmer.sean verizon.net> a écrit dans le message de news:bi1uqh$24u2$1 digitaldaemon.com...Named break and goto are effectively the same thing, right? Labels attach to the beginning or end of their block? I'd rather them attach exactly at the point of flow where the label is encountered, so you can put the label either before or after a block. Simpler than trying to identify thelabelswith a loop or block. Maybe if we removed the goto keyword while in the meantime extending the power of the named break to effectively replace it... it would satiate the whiners, a little bit. ;) Sean "Mike Wynn" <mike.wynn l8night.co.uk> wrote in message news:bi1t45$227t$1 digitaldaemon.com...withoutto continue (a little) the old goto debate, one of the uses of goto is to get to the end of a block from an ifI think that labelled break and continue should only allows a target that instruction that already support break or continue. If we need more power (i.e. arbitrary target) we can (and should uses goto). That way, break would always mean that we break a loop (or a switch) and continue that we continue a loop (or maybe a case if continue is used for fall-through). So for example, it would not be possible to do an infinite loop like above using break...writing a 1000 nexted if else's ........ I'd like to be able to write done:{ .... if (...) { if ( ... ) { break done; } } } instead of writing done:do{ .... if (...) { if ( ... ) { break done; } } } while( false );
Aug 21 2003
"Philippe Mori" <philippe_mori hotmail.com> wrote in message news:bi2hn3$2vd3$1 digitaldaemon.com..."Sean L. Palmer" <palmer.sean verizon.net> a écrit dans le message de news:bi1uqh$24u2$1 digitaldaemon.com...attachNamed break and goto are effectively the same thing, right? Labelsatto the beginning or end of their block? I'd rather them attach exactlylabelthe point of flow where the label is encountered, so you can put thetheeither before or after a block. Simpler than trying to identify thelabelswith a loop or block. Maybe if we removed the goto keyword while in the meantime extending the power of the named break to effectively replace it... it would satiateread the code .... `} while( false);` its only every run once, no infinite loop, its just a do..while loop to allow break to break from it instead of goto to the statement just after the loop end (break breaks from loop it does not goto label)whiners, a little bit. ;) Sean "Mike Wynn" <mike.wynn l8night.co.uk> wrote in message news:bi1t45$227t$1 digitaldaemon.com...withoutto continue (a little) the old goto debate, one of the uses of goto is to get to the end of a block from an ifSo for example, it would not be possible to do an infinite loop like above using break...writing a 1000 nexted if else's ........ I'd like to be able to write done:{ .... if (...) { if ( ... ) { break done; } } } instead of writing done:do{ .... if (...) { if ( ... ) { break done; } } } while( false );
Aug 21 2003
"Mike Wynn" <mike.wynn l8night.co.uk> a écrit dans le message de news:bi3ngf$1nn4$2 digitaldaemon.com..."Philippe Mori" <philippe_mori hotmail.com> wrote in message news:bi2hn3$2vd3$1 digitaldaemon.com...exactly"Sean L. Palmer" <palmer.sean verizon.net> a écrit dans le message de news:bi1uqh$24u2$1 digitaldaemon.com...attachNamed break and goto are effectively the same thing, right? Labelsto the beginning or end of their block? I'd rather them attachatthelabelthe point of flow where the label is encountered, so you can put theeither before or after a block. Simpler than trying to identify thelabelswith a loop or block. Maybe if we removed the goto keyword while in the meantime extendingfromthepower of the named break to effectively replace it... it would satiateread the code .... `} while( false);` its only every run once, no infinite loop, its just a do..while loop to allow break to break from it instead of goto to the statement just after the loop end (break breakswhiners, a little bit. ;) Sean "Mike Wynn" <mike.wynn l8night.co.uk> wrote in message news:bi1t45$227t$1 digitaldaemon.com...withoutto continue (a little) the old goto debate, one of the uses of goto is to get to the end of a block from an ifSo for example, it would not be possible to do an infinite loop like above using break...writing a 1000 nexted if else's ........ I'd like to be able to write done:{ .... if (...) { if ( ... ) { break done; } } } instead of writing done:do{ .... if (...) { if ( ... ) { break done; } } } while( false );loop it does not goto label)The original code has a while but not the suggested remplacement... but not I see that break would mean goto after labelled instruction while continue would be generally equivalent to goto except that continue will not do the initialisation part or a for instruction. I haven't noticed before that the meaning was different that with a goto in such a case... so effectivelly they could be usefull on occasion as they would better document the code... void f(int a) { ext_loop : for (int i = 0; i < 10; ++i) { while (1) { if (a == 0) break ext_loop; // 1 if (a == 1) goto ext_loop; // 2 if (a == 2) continue ext_loop; // 3 } } } would essentially be equivalent to : void f(int a) { { ext_loop_a : int i = 0; ext_loop_b : for ( ; i < 10; ++i) { while (1) { if (a == 0) goto ext_loop_c; // 1 if (a == 1) goto ext_loop_a; // 2 if (a == 2) goto ext_loop_b; // 3 } } ext_loop_c: } } I know, f will loop forever if a is 2...
Aug 21 2003
That's certainly interesting! Sean "Philippe Mori" <philippe_mori hotmail.com> wrote in message news:bi4175$2662$1 digitaldaemon.com...The original code has a while but not the suggested remplacement... but not I see that break would mean goto after labelled instruction while continue would be generally equivalent to goto except that continue will not do the initialisation part or a for instruction. I haven't noticed before that the meaning was different that with a goto in such a case... so effectivelly they could be usefull on occasion as they would better document the code... void f(int a) { ext_loop : for (int i = 0; i < 10; ++i) { while (1) { if (a == 0) break ext_loop; // 1 if (a == 1) goto ext_loop; // 2 if (a == 2) continue ext_loop; // 3 } } } would essentially be equivalent to : void f(int a) { { ext_loop_a : int i = 0; ext_loop_b : for ( ; i < 10; ++i) { while (1) { if (a == 0) goto ext_loop_c; // 1 if (a == 1) goto ext_loop_a; // 2 if (a == 2) goto ext_loop_b; // 3 } } ext_loop_c: } } I know, f will loop forever if a is 2...
Aug 22 2003
"Mike Wynn" <mike.wynn l8night.co.uk> wrote in message news:bi3ngf$1nn4$2 digitaldaemon.com...fromread the code .... `} while( false);` its only every run once, no infinite loop, its just a do..while loop to allow break to break from it instead of goto to the statement just after the loop end (break breaks"Mike Wynn" <mike.wynn l8night.co.uk> wrote in message news:bi1t45$227t$1 digitaldaemon.com...withoutto continue (a little) the old goto debate, one of the uses of goto is to get to the end of a block from an ifwriting a 1000 nexted if else's ........ I'd like to be able to write done:{ .... if (...) { if ( ... ) { break done; } } }loop it does not goto label)I don't see what's so superior about the above versus this: { .... if (...) { if ( ... ) { goto done; } } } done: Yes, you can misuse goto. But you can misuse the hell out named break if you tried to. ;) or HAD to. 8) Sean
Aug 22 2003
"Sean L. Palmer" <palmer.sean verizon.net> wrote in message news:bi4io8$31ck$1 digitaldaemon.com..."Mike Wynn" <mike.wynn l8night.co.uk> wrote in message news:bi3ngf$1nn4$2 digitaldaemon.com...not a great deal, only that 'goto' contains no implicit direction break implied down the code and out the loop, and when cutting and pasting, if you mode code outside the `done` loop you get an error.I don't see what's so superior about the above versus this: { .... if (...) { if ( ... ) { goto done; } } } done:"Mike Wynn" <mike.wynn l8night.co.uk> wrote in message news:bi1t45$227t$1 digitaldaemon.com...withoutto continue (a little) the old goto debate, one of the uses of goto is to get to the end of a block from an ifwriting a 1000 nexted if else's ........ I'd like to be able to write done:{ .... if (...) { if ( ... ) { break done; } } }Yes, you can misuse goto. But you can misuse the hell out named break if you tried to. ;) or HAD to. 8)but not in quite the same way, you can not break/continue from a loop you are not within.
Aug 22 2003
"Mike Wynn" <mike.wynn l8night.co.uk> wrote in message news:bi1t45$227t$1 digitaldaemon.com...to continue (a little) the old goto debate, one of the uses of goto is to get to the end of a block from an if without writing a 1000 nexted if else's ........ I'd like to be able to write done:{ .... if (...) { if ( ... ) { break done; } } } instead of writing done:do{ .... if (...) { if ( ... ) { break done; } } } while( false );I think it'd be better called "break from block to label's scope". If you can do it for any statement, what about mylabel: break; is that statement just skipped or does break break out of something else? This sounds like a good idea, although it doesn't exactly replace goto. I tend to think those loop tricks are more of a hack than using goto, this seems like a pretty good compromise.
Aug 21 2003