Labeled Break (nothing at all whatsoever to do with GOTO)

php.internals

Sara Golemon

20 years ago
But first, this word from our sponsor: Group A wants anything resembling goto to burn in the fires of hell Group B wants full non-crippled goto or nothing at all Group C wants partial goto (non-backward jumping) or nothing at all Groups B and C both (generally) want it called either GOTO or JUMP, not BREAK Since no group this size will ever come to an agreement on something this divisive, I'd like to turn the topic to a completely different language feature which (might) please enough people to get a rousing consensus. Actual labeled breaks. Not the break+jump that was proposed earlier in the guise of a break statement, but an actual straightforward, no funny-business labeled break which does no more and no less than the current break N; construct, but allows the use of identifier labels rather than numbers which may change as the result of the addition or removal of break containers. http://libssh2.org/patches/true_labeled_break.diff Usage: while FOO ($condition) { /* statements */ break FOO; /* more statements */ } Or a stacked example: for FOO(;;) { while BAR (true) { foreach BAZ ($arr as $val) { switch Foof ($value) { default: do Plop { break FOO; } while (false); } } } } Notes on this implementation: * Labels can't be repeated in an ancestral line. For example, the parser will throw an ERROR on the following: while FOO(true) { while FOO(true) { break FOO; } } * Labels can be repeated by siblings. I'm not married to this, and it certainly has WTF potential. This behavior is easily modified to throw an error. I left it permissable because there was no technical reason to disallow it. For example, the following is okay: while FOO(true) { break; } while FOO(true) { break FOO; } * Labeled breaks also apply to continue; For example: foreach FOO($arr as $key => $val) { if ($key % 2) continue FOO; if (empty(%key)) break FOO; }

Robert Cummings

20 years ago
On Tue, 2005-11-29 at 20:40, Sara Golemon wrote:
> But first, this word from our sponsor: > Group A wants anything resembling goto to burn in the fires of hell > Group B wants full non-crippled goto or nothing at all > Group C wants partial goto (non-backward jumping) or nothing at all > Groups B and C both (generally) want it called either GOTO or JUMP, not > BREAK > > Since no group this size will ever come to an agreement on something this > divisive, I'd like to turn the topic to a completely different language > feature which (might) please enough people to get a rousing consensus. > > Actual labeled breaks. Not the break+jump that was proposed earlier in the > guise of a break statement, but an actual straightforward, no funny-business > labeled break which does no more and no less than the current break N; > construct, but allows the use of identifier labels rather than numbers which > may change as the result of the addition or removal of break containers. > > http://libssh2.org/patches/true_labeled_break.diff > > Usage: > > while FOO ($condition) { > /* statements */ > break FOO; > /* more statements */ > } > > Or a stacked example: > > for FOO(;;) { > while BAR (true) { > foreach BAZ ($arr as $val) { > switch Foof ($value) { > default: > do Plop { > break FOO; > } while (false); > } > } > } > } > > Notes on this implementation: > > * Labels can't be repeated in an ancestral line. For example, the parser > will throw an ERROR on the following: > while FOO(true) { > while FOO(true) { > break FOO; > } > } > > * Labels can be repeated by siblings. I'm not married to this, and it > certainly has WTF potential. This behavior is easily modified to throw an > error. I left it permissable because there was no technical reason to > disallow it. For example, the following is okay: > while FOO(true) { > break; > } > while FOO(true) { > break FOO; > } > > * Labeled breaks also apply to continue; For example: > foreach FOO($arr as $key => $val) { > if ($key % 2) continue FOO; > if (empty(%key)) break FOO; > }
Hello, I represent group B (not in any way officially or anything else that might give my words an iota of weight), but I (*cough cough*) WE think that the above break system would make a terrible system for finite state machines. Additionally at this time I'd like to make clear that we are in support for full uncrippled break WITHIN scope. Group A can feel free to travel to the burning fires of hell and have a barbecue, and group C should join us so that at least they get what they want as a subset. As an aside, from what I've read, the multitude were in favour of unrestricted goto. Quite a few were in favour of none at all (but not as many as in group B) and those in favour of none at all had a large subset that were in favour of unrestricted goto in the event that group B should get their way :) Cheers, Rob.
-- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

Sara Golemon

20 years ago
> Hello, I represent group B (not in any way officially or anything else > that might give my words an iota of weight), but I (*cough cough*) WE > think that the above break system would make a terrible system for > finite state machines. >
Good, 'cause that's not its purpose. This doesn't supplant GOTO or preclude it. This is a different topic about a different feature which just happens to touch on SOME similar talking points.
> Additionally at this time I'd like to make clear that we are in support > for full uncrippled break WITHIN scope. Group A can feel free to travel > to the burning fires of hell and have a barbecue, and group C should > join us so that at least they get what they want as a subset. >
Lead on the charge good sir... lead on.
> As an aside, from what I've read, the multitude were in favour of > unrestricted goto. Quite a few were in favour of none at all (but not as > many as in group B) and those in favour of none at all had a large > subset that were in favour of unrestricted goto in the event that group > B should get their way :) >
Not to put too fine a point on it, but there's a limited subset of the voices on this list that carry the weight needed to push a feature like goto into the engine. Amongst those voices there is a much less decisive quorum. -Sara

Marcus Börger

20 years ago
Hello Sara, nice work, clean patch, good solution - thanks! what more can one say? best regards marcus p.s.: I'll have the thousands of replies on this thread on ignore :-) Wednesday, November 30, 2005, 2:40:32 AM, you wrote:
> But first, this word from our sponsor: > Group A wants anything resembling goto to burn in the fires of hell > Group B wants full non-crippled goto or nothing at all > Group C wants partial goto (non-backward jumping) or nothing at all > Groups B and C both (generally) want it called either GOTO or JUMP, not > BREAK
> Since no group this size will ever come to an agreement on something this > divisive, I'd like to turn the topic to a completely different language > feature which (might) please enough people to get a rousing consensus.
> Actual labeled breaks. Not the break+jump that was proposed earlier in the > guise of a break statement, but an actual straightforward, no funny-business > labeled break which does no more and no less than the current break N; > construct, but allows the use of identifier labels rather than numbers which > may change as the result of the addition or removal of break containers.
> http://libssh2.org/patches/true_labeled_break.diff
> Usage:
> while FOO ($condition) { > /* statements */ > break FOO; > /* more statements */ > }
> Or a stacked example:
> for FOO(;;) { > while BAR (true) { > foreach BAZ ($arr as $val) { > switch Foof ($value) { > default: > do Plop { > break FOO; > } while (false); > } > } > } > }
> Notes on this implementation:
> * Labels can't be repeated in an ancestral line. For example, the parser > will throw an ERROR on the following: > while FOO(true) { > while FOO(true) { > break FOO; > } > }
> * Labels can be repeated by siblings. I'm not married to this, and it > certainly has WTF potential. This behavior is easily modified to throw an > error. I left it permissable because there was no technical reason to > disallow it. For example, the following is okay: > while FOO(true) { > break; > } > while FOO(true) { > break FOO; > }
> * Labeled breaks also apply to continue; For example: > foreach FOO($arr as $key => $val) { > if ($key % 2) continue FOO; > if (empty(%key)) break FOO; > }
Best regards, Marcus

Pierre Joye

20 years ago
On Wed, 30 Nov 2005 02:52:59 +0100 helly@php.net (Marcus Boerger) wrote:
> Hello Sara, > > nice work, clean patch, good solution - thanks! what more can one > say?
commit? :) --Pierre

Sara Golemon

20 years ago
>> Hello Sara, >> >> nice work, clean patch, good solution - thanks! what more can one >> say? > > commit? :) >
Oh how you both love to tease me :p It occured to me on the way onto the train that this construct doesn't need pass_two(). When I get home to more bandwidth I'll cook up a simplified version that resolves break distance in zend_do_brk_cont() and frees the labels in do_end_loop(). -Sara

Sara Golemon

20 years ago
> It occured to me on the way onto the train that this construct doesn't > need pass_two(). When I get home to more bandwidth I'll cook up a > simplified version that resolves break distance in zend_do_brk_cont() and > frees the labels in do_end_loop(). >
Okay, simpler/leaner implementation now available. The new version only touches zend_compile.[ch] and zend_language_parser.y though the functionality is the same. http://libssh2.org/patches/true_labeled_break.diff -Sara

Dmitry Stogov

20 years ago
Is it possible to not extend "zend_brk_cont_element" structures? They are used during runtime. Thanks. Dmitry.

Ilia A.

20 years ago
I guess I fall into Group B, and I must say that I'd prefer either to see goto/jump like construct or nothing at all. Be it a crippled goto/jump or labeled breaks. So, my vote is a -1. Ilia

Hartmut Holzgraefe

20 years ago
Ilia Alshanetsky wrote:
> I guess I fall into Group B, and I must say that I'd prefer either to > see goto/jump like construct or nothing at all. Be it a crippled > goto/jump or labeled breaks. So, my vote is a -1.
think of not in the context of GOTO but as in 'break _number_;" finally done right'
-- Hartmut Holzgraefe, Senior Support Engineer . MySQL AB, www.mysql.com

Hannes Magnusson

20 years ago
Elegant solution, however, I'd prefer while(true) FOO { }. while FOO(true) {} looks like a function call... On 11/30/05, Sara Golemon <pollita@php.net> wrote:

Ron Korving

20 years ago
I loved Joao Cruz Morais idea of using the 'as' keyword in this: while (true) as outer_cycle { $i = 0; while (true) if($i++ == 10) break outer_cycle; } I think it's really clear and with this syntax you (at least in my opinion) kinda loose the feeling of needing all caps for a label name. Somehow it feels less like a constant. This is absolutely personal though, and could be just between my ears, not yours... I just love this syntax ;) Ron "Hannes Magnusson" <hannes.magnusson@gmail.com> schreef in bericht news:7f3ed2c30511292327p1ffae378n9c2bfb01bdb333d3@mail.gmail.com... Elegant solution, however, I'd prefer while(true) FOO { }. while FOO(true) {} looks like a function call... On 11/30/05, Sara Golemon <pollita@php.net> wrote:

Sebastian Kugler

20 years ago
On 11/30/05, Ron Korving <r.korving@xit.nl> wrote:
> I loved Joao Cruz Morais idea of using the 'as' keyword in this: > > while (true) as outer_cycle { > $i = 0; > while (true) > if($i++ == 10) break outer_cycle; > }
Me too - it's so stunningly obvious to understand at first sight, compared to while LABEL (cond) { Don't know of course if there are technical reasons against this proposal, just my 2 cents from the user's perspective. --Sebastian

Hartmut Holzgraefe

20 years ago
Ron Korving wrote:
> I loved Joao Cruz Morais idea of using the 'as' keyword in this: > > while (true) as outer_cycle { > $i = 0; > while (true) > if($i++ == 10) break outer_cycle; > }
might become a bit confusing with foreach ($array as $val) as someloop { but that aside i like the syntax :)
-- Hartmut Holzgraefe, Senior Support Engineer . MySQL AB, www.mysql.com

Dmitry Stogov

20 years ago
Hi Sara, This "break LABEL" construct does exactly the same as "break NUM", Also I don't like syntax for loops that you suggested. I prefer "LABEL: while(1) {...}" instead of while LABEL (1) {...}". This construct has logic and make sense, but I am not sure that we should incrise complication of PHP compiler without any serious benefits. Readability is the only one benefit of this patch. May be I missed something? I didn't look into patch deep. Thanks. Dmitry.

Hannes Magnusson

20 years ago
IMO labeld breaks are *alot* more readable then break NUM; On 11/30/05, Dmitry Stogov <dmitry@zend.com> wrote:

David M. Patterson

20 years ago
Not only are labeled breaks more readable, they are far more maintainable, especially when nested. With break NUM, you have to change the NUMs every time you change the nesting. I've shot myself in the foot several times that way. Just my two cents as a long-time PHP user Dave Hannes Magnusson said:
> IMO labeld breaks are *alot* more readable then break NUM;
On 11/30/05, Dmitry Stogov <dmitry@zend.com> wrote:
> Hi Sara, > > This "break LABEL" construct does exactly the same as "break NUM", > > Also I don't like syntax for loops that you suggested. > I prefer "LABEL: while(1) {...}" instead of while LABEL (1) {...}". > > This construct has logic and make sense, but I am not sure that we should > incrise complication of PHP compiler without any serious benefits. > Readability is the only one benefit of this patch. > > May be I missed something? I didn't look into patch deep. > > Thanks. Dmitry. > > > -----Original Message----- > > From: Sara Golemon [mailto:pollita@php.net] > > Sent: Wednesday, November 30, 2005 4:41 AM > > To: internals@lists.php.net > > Subject: [PHP-DEV] Labeled Break (nothing at all whatsoever > > to do with GOTO) > > > > > > But first, this word from our sponsor: > > Group A wants anything resembling goto to burn in the fires > > of hell Group B wants full non-crippled goto or nothing at > > all Group C wants partial goto (non-backward jumping) or > > nothing at all Groups B and C both (generally) want it called > > either GOTO or JUMP, not BREAK > > > > Since no group this size will ever come to an agreement on > > something this divisive, I'd like to turn the topic to a > > completely different language feature which (might) please > > enough people to get a rousing consensus. > > > > Actual labeled breaks. Not the break+jump that was proposed > > earlier in the guise of a break statement, but an actual > > straightforward, no funny-business labeled break which does > > no more and no less than the current break N; construct, but > > allows the use of identifier labels rather than numbers which > > may change as the result of the addition or removal of break > > containers. > > > > http://libssh2.org/patches/true_labeled_break.diff > > > > Usage: > > > > while FOO ($condition) { > > /* statements */ > > break FOO; > > /* more statements */ > > } > > > > Or a stacked example: > > > > for FOO(;;) { > > while BAR (true) { > > foreach BAZ ($arr as $val) { > > switch Foof ($value) { > > default: > > do Plop { > > break FOO; > > } while (false); > > } > > } > > } > > } > > > > Notes on this implementation: > > > > * Labels can't be repeated in an ancestral line. For > > example, the parser will throw an ERROR on the following: > > while FOO(true) { > > while FOO(true) { > > break FOO; > > } > > } > > > > * Labels can be repeated by siblings. I'm not married to > > this, and it certainly has WTF potential. This behavior is > > easily modified to throw an error. I left it permissable > > because there was no technical reason to disallow it. For > > example, the following is okay: while FOO(true) { > > break; > > } > > while FOO(true) { > > break FOO; > > } > > > > * Labeled breaks also apply to continue; For example: > > foreach FOO($arr as $key => $val) { > > if ($key % 2) continue FOO; > > if (empty(%key)) break FOO; > > } > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Sara Golemon

20 years ago
> This "break LABEL" construct does exactly the same as "break NUM", > > May be I missed something? I didn't look into patch deep. >
Your take is spot-on. This isn't an extension of functionality, just a "numbered breaks with a name" which is something I've heard requested from several corners (including @zend.com) as a "wouldn't it be nice..."
> Also I don't like syntax for loops that you suggested. > I prefer "LABEL: while(1) {...}" instead of while LABEL (1) {...}". >
I agree that the positioning of the label has an inherent ugliness to it. I avoided "LABEL: while (1) { }" however, in order to avoid conflicting with and complicating the GOTO discussion. Since (if goto was added as well) this syntax could create an ambiguity in what the label means. Since you'd like the label to be moved out of zend_brk_cont_element, then perhaps we can allow this syntax to pull double duty... LABEL: whlie(1) { break LABEL; <-- el->brk continue LABEL; <-- el->cont goto LABEL; <-- opline->u.opline_num break OTHERLABEL; <-- error continue OTHERLABEL; <-- error goto OTHERLABEL; <-- opline->u.opline_num } OTHERLABEL: nonBreakContainerStatement();
> This construct has logic and make sense, but I am not sure that we should > incrise complication of PHP compiler without any serious benefits. > Readability is the only one benefit of this patch. >
So the question is: How serious is the gain in readability/maintainability? -Sara

Bart de Boer

20 years ago
Sounds good from a syntax perspective... :) Sara Golemon wrote:

Jochem Maas

20 years ago
Sara Golemon wrote: ...
> Your take is spot-on. This isn't an extension of functionality, just a > "numbered breaks with a name" which is something I've heard requested > from several corners (including @zend.com) as a "wouldn't it be nice..." >
I wonder if the need for labelled breaks/continues might dissapear (in practice) if those people who could most do with them are given 'goto' (without the no-go-backwards limitation) instead? Everytime I see heavily nested 'break n' statements it makes me wince and the only times there seems to be no real/decent alternative to such nesting is when building some kind of state machine ... state machines being one of the few concrete examples to support the implementation of 'goto' in the first place, no? ...
> Since you'd like the label to be moved out of zend_brk_cont_element, > then perhaps we can allow this syntax to pull double duty...
devils advocate: what happens when I want to place a 'goto' label just before a while or foreach loop (upon which I haven't put a label)? I ask because I assume that the following 2 statements should be identical no:? <?php LABEL: while(1) { /* ..etc */ ?> <?php LABEL: while(1) { /* ..etc */ ?>

Bart de Boer

20 years ago
> devils advocate: > what happens when I want to place a 'goto' label just before a while or > foreach > loop (upon which I haven't put a label)? I ask because I assume that the > following 2 > statements should be identical no:? >
I think there would be no such thing as a 'goto' or 'break' label. There would be just labels. You could use them with 'goto' and/or 'break' together: goto LABEL: ... LABEL:while (cond) { if (cond) break LABEL; }

Sara Golemon

20 years ago
> what happens when I want to place a 'goto' label just before a while or > foreach > loop (upon which I haven't put a label)? I ask because I assume that the > following 2 > statements should be identical no:? > > <?php > LABEL: while(1) { > /* ..etc */ > ?> > > <?php > LABEL: > while(1) { > /* ..etc */ > ?> >
PHP's parser gives no importance to whitespace, so yes, these two are identical. In the dual-purpose vision I had for these labels, all labels would be usable as GOTO targets. Labels which are followed *immediately* by a break container construct (for, foreach, while, do-while, switch) would also be usable as break/continue targets. Note that in these example, goto LABEL; and continue lABEL; are *not* the same statement. Goto would restart state loops such as for() and foreach() from initial positions. -Sara

Jochem Maas

20 years ago
thanks for the explanation Sara, :-), as always your manner and ideas are an example to the 'php core', 'we' (they) are lucky to have you :-) Sara Golemon wrote:

Dmitry Stogov

20 years ago
Hi Sara, I made another patch that is based on your ideas. 1) It uses "right" syntax: LABEL: while(1) { break LABEL; } 2) It doesn't allow usage of same label for different loops L1: while(1) {...} L1: while(1) {...} 3) It doesn't use executor data structures 4) It allows reuse of same labels for jump/goto (as was done in your first patch). It already declares "jump LABEL;" operator but emits error for now. I think this patch can be committed and then we can discuss jump/goto. Thanks. Dmitry.

Sara Golemon

20 years ago
We're definately on the same page as far as implementation goals, but I can't help but notice one problem: * labels aren't scoped to functions. The break container checks prevent casual jumping, but: FOO: do { } while (0); function bar() { do { break FOO; } while (0); } Actually compiles legally. Of course the actual break stays within its local container, but if/when Jump is introduced to the mix....well... all bets are off... -Sara ----- Original Message ----- From: "Dmitry Stogov" <dmitry@zend.com> To: "'Sara Golemon'" <pollita@php.net>; <internals@lists.php.net> Cc: "Zeev Suraski" <zeev@zend.com>; "Stanislav Malyshev" <stas@zend.com> Sent: Thursday, December 01, 2005 2:45 AM Subject: RE: [PHP-DEV] Labeled Break (nothing at all whatsoever to do withGOTO)

Stanislav Malyshev

20 years ago
SG>>* labels aren't scoped to functions. The break container checks prevent SG>>casual jumping, but: SG>> SG>>FOO: do { } while (0); SG>>function bar() { SG>> do { break FOO; } while (0); SG>>} This shouldn't work, of course.
-- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/ +972-3-6139665 ext.115

Dmitry Stogov

20 years ago
Good catch. Thanks. I'll fix this and send a new patch. Dmitry.

Dmitry Stogov

20 years ago
I hope now I didn't making idiot's mistake. Dmitry.

Sara Golemon

20 years ago
> I made another patch that is based on your ideas. > > 1) It uses "right" syntax: > > LABEL: while(1) { > break LABEL; > } > > 2) It doesn't allow usage of same label for different loops > > L1: while(1) {...} > L1: while(1) {...} > > 3) It doesn't use executor data structures > > 4) It allows reuse of same labels for jump/goto (as was done in your > first patch). It already declares "jump LABEL;" operator but emits > error for now. > > I think this patch can be committed and then we can discuss > jump/goto. >
I agree. This gives us a clear, unambiguous syntax, puts no additional load (either memory or cpu) on the executor and sets the groundwork for jump/goto *if* it's deemed worthy of PHP. To just just offer out piccune little points (not trying to kvetch or anything): * Declarations of zend_label *label; and long distance = 1; in zend_do_brk_cont() have a mix of spaces and tabs in their indentation rather than exclusively tabs. * zend_error(E_COMPILE_ERROR, "%s to to label '%R', also in zend_do_brk_cont() has a superfluous 'to'. Thanks Dimitry! Andi/Zeev- Can one/both of you weigh in on this at this point? -Sara

Jani Taskinen

20 years ago
I don't care what kind of GOTO I get as long as I get one. Right now I only see need for the forward jumping version, but I don't mind if you could jump backwards too. :) And I also want VETO on each and every bug report about it. :) If anyone dares to report a bug with goto in it -> automatic bogus. We make it work for the simple usage it's meant for and if someone uses it wrong, too bad. :) And the labeled breaks you suggest now can burn in hell! --Jani On Tue, 29 Nov 2005, Sara Golemon wrote:
> > But first, this word from our sponsor: > Group A wants anything resembling goto to burn in the fires of hell > Group B wants full non-crippled goto or nothing at all > Group C wants partial goto (non-backward jumping) or nothing at all > Groups B and C both (generally) want it called either GOTO or JUMP, not > BREAK > > Since no group this size will ever come to an agreement on something this > divisive, I'd like to turn the topic to a completely different language > feature which (might) please enough people to get a rousing consensus. > > Actual labeled breaks. Not the break+jump that was proposed earlier in the > guise of a break statement, but an actual straightforward, no funny-business > labeled break which does no more and no less than the current break N; > construct, but allows the use of identifier labels rather than numbers which > may change as the result of the addition or removal of break containers. > > http://libssh2.org/patches/true_labeled_break.diff > > Usage: > > while FOO ($condition) { > /* statements */ > break FOO; > /* more statements */ > } > > Or a stacked example: > > for FOO(;;) { > while BAR (true) { > foreach BAZ ($arr as $val) { > switch Foof ($value) { > default: > do Plop { > break FOO; > } while (false); > } > } > } > } > > Notes on this implementation: > > * Labels can't be repeated in an ancestral line. For example, the parser > will throw an ERROR on the following: > while FOO(true) { > while FOO(true) { > break FOO; > } > } > > * Labels can be repeated by siblings. I'm not married to this, and it > certainly has WTF potential. This behavior is easily modified to throw an > error. I left it permissable because there was no technical reason to > disallow it. For example, the following is okay: > while FOO(true) { > break; > } > while FOO(true) { > break FOO; > } > > * Labeled breaks also apply to continue; For example: > foreach FOO($arr as $key => $val) { > if ($key % 2) continue FOO; > if (empty(%key)) break FOO; > } > >
-- Give me your money at @ <http://pecl.php.net/wishlist.php/sniper> Donating money may make me happier and friendlier for a limited period! Death to all 4 letter abbreviations starting with P!

Bart de Boer

20 years ago
Sara++ :) Although I prefer BAR:while (This would go better with goto if someone would want to implement that some day.) I'd settle for while BAR since I don't care about goto anyway. So: foreach BAZ ($arr as $val) +1 BAZ: foreach ($arr as $val) +2 foreach as BAZ ($arr as $val) -2 ('as' can be a bit confusing here) Sara Golemon wrote:

Ron Korving

20 years ago
I'd say: foreach ($arr as $val) as foo { if (true) break foo; } I don't like the idea at all that labeled breaks are in any way connected to 'goto' usage. It's my opinion that the two can coexist without a problem, and that's how I would prefer to see it being used. Besides, BAR:while () { } would not do well with a future goto-implementation, because that would mean it would jump to the beginning of the loop, and not out of the loop. Maybe you mean to say that labels for goto and break can exist in the same collection, but I wouldn't be a fan of that at all. Semantically, 'goto' behavior is very different from break-behavior. With a break I expect to leave a certain construct that has a certain name, with goto I expect to jump to the line of code that was labeled with a name. I think the usage is different enough not to want those labels to be the same kind of things. Maybe other people disagree, but my point is that the difference in semantics is really something to consider. When you make break-labels the same as goto-labels, I would find this a bit weird to read: FOO: while (true) { ... } Will it be used for breaking out of the loop or for jumping to the loop? Should I expect a goto statement somewhere in this file? - Ron "Bart de Boer" <bart@mediawave.nl> schreef in bericht news:AA.64.14828.88C6D834@pb1.pair.com...

Bart de Boer

20 years ago
I wasn't thinking about goto or break. I was thinking about *labels* and using them in a consistent manner with PHP. For example: while (cond) { LABEL: while (cond) { if (cond) { break LABEL; } else { some_command OTHERLABEL; } } } OTHERLABEL: Or Sara's way: while (cond) { while LABEL (cond) { if (cond) { break LABEL; } else { some_command OTHERLABEL; } } } OTHERLABEL; In the last example. Would OTHERLABEL; be possible technically? Say, *if* we'd want to use it this way some day? If so, I'll give it +2. Ron Korving wrote:

Stanislav Malyshev

20 years ago
SG>>Actual labeled breaks. Not the break+jump that was proposed earlier in the I think the idea is OK, though I don't like a syntax. There is a standard for/while syntax which is used by a lot of procedural languages, and I see no reason to break it. I see nothing wrong with using FOO: for label. SG>>* Labels can be repeated by siblings. I'm not married to this, and it I don't think this is really needed, though it's doable and has some logic in it (after all, once the labelled block ends, the label is not longer existing). SG>>* Labeled breaks also apply to continue; For example: yes, I think it's a good way to do it.
-- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/ +972-3-6139665 ext.115

Hartmut Holzgraefe

20 years ago
Stanislav Malyshev wrote:
> SG>>* Labeled breaks also apply to continue; For example: > > yes, I think it's a good way to do it.
oh, totally forgot about that, another strong reason for having it in parallel to any GOTO solution we come up with
-- Hartmut Holzgraefe, Senior Support Engineer . MySQL AB, www.mysql.com