RE: GOTO and/or BREAK LABEL

php.internals

Ford, Mike [LSS]

20 years ago
On 07 March 2006 09:28, Dmitry Stogov wrote:
> Please reviw and vote. > > 1) goto and break label > 2) goto only (like C) > 3) break label only (like Java) > 4) nothing
1) +0.25 2) -1e38 3) +1e38 4) -infinity Or, in other words, I want labelled break, and I don't want to have to emulate it with goto. As a user who spent several *days* tracking down a subtle bug caused by a continue n that hadn't been altered to continue n+1, I regard labelled break as a vital addition -- for me, it's not the frequency with which it is used (very low, I agree), but the incredibly disproportionate maintenance burden (potentially extremely high). In my case, I was adding a level to a heavily nested looping/conditional structure (7 or 8 levels deep) extending over several hundred lines, and out of the few break/continue statements that needed adjusting I missed just one. If they had been labelled breaks, there would have been *no* maintenance problem, and I'd have had several more days on the next step. If the "Java-like" syntax is seen as confusing, what about, as in some other languages, interpolating the label into the for/foreach/while statement: for (....) label {...} or for label (...) {...} This is clearly a different animal from a goto target label: (but should be in the same namespace, of course). OK, I'll shut up now and slope off into a corner. (Perhaps I should design my own language whilst I'm there ... but nah, did that decades ago and got bored -- prefer higher-level programming these days!) Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: m.ford@leedsmet.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

Xuefer Tinys

20 years ago

Steph

20 years ago
Please, Xuefer! Your vote was already recorded, shhh! ----- Original Message ----- From: "Xuefer" <xuefer@gmail.com> To: "Ford, Mike" <M.Ford@leedsmet.ac.uk> Cc: "Dmitry Stogov" <dmitry@zend.com>; <internals@lists.php.net> Sent: Thursday, March 09, 2006 5:19 AM Subject: Re: [PHP-DEV] GOTO and/or BREAK LABEL

Dmitry Stogov

20 years ago
Hi, The solution (2) - "goto only" is the winner. So in case of no serious objections, I'll commit the "goto.diff" patch in 24 hour. The last question: What do you thin about Andi's solution about using "jump" instead of "goto"? It may make sense, because it is not a full analog of C's goto statement. It is a limited "goto". It allows jump back and forward, but not INTO loops and switch statements. Thanks. Dmitry.

Derick Rethans

20 years ago
On Thu, 9 Mar 2006, Dmitry Stogov wrote:
> Hi, > > The solution (2) - "goto only" is the winner. > So in case of no serious objections, I'll commit the "goto.diff" patch in 24 > hour. > > The last question: > What do you thin about Andi's solution about using "jump" instead of "goto"?
I don't really mind... but I wonder why you want to do this? Both work equally well and most people are familiar with the term "goto". Derick

Dmitry Stogov

20 years ago
I am indifferent - "goto" or "jump", but may be others don't. Thanks. Dmitry.

Andrey Hristov

20 years ago
Hi, Dmitry Stogov wrote:
> I am indifferent - "goto" or "jump", but may be others don't.
what about `escape`?
> Thanks. Dmitry. > > >>-----Original Message----- >>From: Derick Rethans [mailto:derick@php.net] >>Sent: Thursday, March 09, 2006 11:09 AM >>To: Dmitry Stogov >>Cc: internals@lists.php.net >>Subject: Re: [PHP-DEV] GOTO and/or BREAK LABEL (conclusion) >> >> >>On Thu, 9 Mar 2006, Dmitry Stogov wrote: >> >> >>>Hi, >>> >>>The solution (2) - "goto only" is the winner. >>>So in case of no serious objections, I'll commit the >> >>"goto.diff" patch >> >>>in 24 hour. >>> >>>The last question: >>>What do you thin about Andi's solution about using "jump" >> >>instead of >> >>>"goto"? >> >>I don't really mind... but I wonder why you want to do this? >>Both work >>equally well and most people are familiar with the term "goto". >> >>Derick >> >>--
Andrey

Andrey Hristov

20 years ago
Hi, sorry for sending second email. Another choice could be `leave`, which seems better than `escape` (clashes with escaping sequences). Andrey Andrey Hristov wrote:

Jon Dowland

20 years ago
At 1141902889, Andrey Hristov wrote:
> sorry for sending second email. Another choice could be `leave`, which > seems better than `escape` (clashes with escaping sequences).
I think `leave` has too many connotations with `break` and similar commands, and could be misleading.
-- Jon Dowland http://alcopop.org/

Andrey Hristov

20 years ago
Jon Dowland wrote:
> At 1141902889, Andrey Hristov wrote: > >>sorry for sending second email. Another choice could be `leave`, which >>seems better than `escape` (clashes with escaping sequences). > > > I think `leave` has too many connotations with `break` and similar > commands, and could be misleading. >
I don't concur and there is documentation for the language. To get to a language one needs to read a bit of its documentation. In every language I know break leaves the current loop, in PHP it's overloaded that the PC could be set after `n` loops. Andrey

Jon Dowland

20 years ago
At 1141895342, Derick Rethans wrote:
> On Thu, 9 Mar 2006, Dmitry Stogov wrote: > > The last question: What do you thin about Andi's solution about > > using "jump" instead of "goto"? > > I don't really mind... but I wonder why you want to do this? Both work > equally well and most people are familiar with the term "goto".
Seeing as this does not behave the same as the classic C "goto", re-using the term could prove to be misleading and confusing. For this reason I prefer "jump".
-- Jon Dowland http://alcopop.org/

Zeev Suraski

20 years ago
jump makes more sense than goto. We bounced it off in the Paris meeting, IIRC it was fairly popular in case we go down the route of this semantics. Zeev At 10:03 09/03/2006, Dmitry Stogov wrote:

Joao Cruz Morais

20 years ago
At 10:03 09/03/2006, Dmitry Stogov wrote:
>>The last question: >>What do you thin about Andi's solution about using "jump" instead of
"goto"? Great! Yet another keyword. PHP keeps surprising the world...
>>It may make sense, because it is not a full analog of C's goto
statement. It
>>is a limited "goto". It allows jump back and forward, but not INTO
loops and
>>switch statements.
The "break number" syntax will still be available? Otherwise from your words I understand that there is no way of breaking/jumping a lot of nested cycles and still be in a cycle. I wish I could vote for a better version of Java labeled breaks :( João C Morais Zeev Suraski wrote:

Greg Beaver

20 years ago
Dmitry Stogov wrote:
> Hi, > > The solution (2) - "goto only" is the winner. > So in case of no serious objections, I'll commit the "goto.diff" patch in 24 > hour. > > The last question: > What do you thin about Andi's solution about using "jump" instead of "goto"? > > It may make sense, because it is not a full analog of C's goto statement. It > is a limited "goto". It allows jump back and forward, but not INTO loops and > switch statements.
+1 for jump Greg

Bart de Boer

20 years ago
Greg Beaver wrote:
> Dmitry Stogov wrote: >> Hi, >> >> The solution (2) - "goto only" is the winner. >> So in case of no serious objections, I'll commit the "goto.diff" patch in 24 >> hour. >> >> The last question: >> What do you thin about Andi's solution about using "jump" instead of "goto"? >> >> It may make sense, because it is not a full analog of C's goto statement. It >> is a limited "goto". It allows jump back and forward, but not INTO loops and >> switch statements. > > +1 for jump > > Greg
Even though I like "jump", people will most likely be searching for "goto" (PHP manual) or "goto PHP" (Google) when they're trying to find out if PHP has such a functionality. So, maybe it's better to just call it "goto". PHP will give some kind of warning if it is used incorrectly, right? They'll learn soon enough. Bart

Pierre Joye

20 years ago
On Thu, 9 Mar 2006 11:03:48 +0300 dmitry@zend.com ("Dmitry Stogov") wrote:
> Hi, > > The solution (2) - "goto only" is the winner. > So in case of no serious objections, I'll commit the "goto.diff" > patch in 24 hour. > > The last question: > What do you thin about Andi's solution about using "jump" instead of > "goto"? > > It may make sense, because it is not a full analog of C's goto > statement. It is a limited "goto". It allows jump back and forward, > but not INTO loops and switch statements.
+1 to commit the damned thing as it was proposed, goto (2). Everyone will look at goto, not jump (unless you use asm and then you need jmp :) --Pierre

Derick Rethans

20 years ago
On Thu, 9 Mar 2006, Bart de Boer wrote:
> Even though I like "jump", people will most likely be searching for "goto" > (PHP manual) or "goto PHP" (Google) when they're trying to find out if PHP has > such a functionality. So, maybe it's better to just call it "goto". > > PHP will give some kind of warning if it is used incorrectly, right? They'll > learn soon enough.
I fully agree with this. "goto" it should be. Derick

Sara Golemon

20 years ago
> Even though I like "jump", people will most likely be searching for "goto" > (PHP manual) or "goto PHP" (Google) when they're trying to find out if PHP > has > such a functionality. So, maybe it's better to just call it "goto". >
Agreed. As the man said this morning, let's "Consider our Audience". "Goto" is what they'll search for. However, the manual does have a list of redirection translations. We can have http://www.php.net/goto resolve to http://www.php.net/language.control.jump easily enough. Either syntax works. My personal prefference (prior paragraph not withstanding) is "goto".
> PHP will give some kind of warning if it is used incorrectly, right? > They'll > learn soon enough. >
Yes, it'll be an E_PARSE. -Sara

Stanislav Malyshev

20 years ago
BdB>>Even though I like "jump", people will most likely be searching for BdB>>"goto" (PHP manual) or "goto PHP" (Google) when they're trying to BdB>>find out if PHP has such a functionality. So, maybe it's better to BdB>>just call it "goto". For such people we might have a page in the manual saying: goto: see jump :)
-- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/ +972-3-6139665 ext.115

Steph

20 years ago
> BdB>>Even though I like "jump", people will most likely be searching for > BdB>>"goto" (PHP manual) or "goto PHP" (Google) when they're trying to > BdB>>find out if PHP has such a functionality. So, maybe it's better to > BdB>>just call it "goto". > > For such people we might have a page in the manual saying: > goto: see jump
Erm, wouldn't those people who need to refer to the manual be exactly the same people we wanted to protect from goto in the first place? :) jump +1, if it counts - Steph

Pierre Joye

20 years ago
On 3/9/06, Steph Fox <steph@zend.com> wrote:
> > BdB>>Even though I like "jump", people will most likely be searching for > > BdB>>"goto" (PHP manual) or "goto PHP" (Google) when they're trying to > > BdB>>find out if PHP has such a functionality. So, maybe it's better to > > BdB>>just call it "goto". > > > > For such people we might have a page in the manual saying: > > goto: see jump > > Erm, wouldn't those people who need to refer to the manual be exactly the > same people we wanted to protect from goto in the first place? :) > > jump +1, if it counts
You are back to the main problem, you cannot educate people by keeping them away from the "dangerous" functions. Can we not commit this goto and move on?!?

Zeev Suraski

20 years ago
At 19:37 09/03/2006, Pierre wrote:
>On 3/9/06, Steph Fox <steph@zend.com> wrote: > > > BdB>>Even though I like "jump", people will most likely be searching for > > > BdB>>"goto" (PHP manual) or "goto PHP" (Google) when they're trying to > > > BdB>>find out if PHP has such a functionality. So, maybe it's better to > > > BdB>>just call it "goto". > > > > > > For such people we might have a page in the manual saying: > > > goto: see jump > > > > Erm, wouldn't those people who need to refer to the manual be exactly the > > same people we wanted to protect from goto in the first place? :) > > > > jump +1, if it counts > >You are back to the main problem, you cannot educate people by keeping >them away from the "dangerous" functions.
Uhm, of course you can. Avoiding problems is by far the best way of solving them. But it has nothing to do with our topic. Zeev

Stanislav Malyshev

20 years ago
SF>>Erm, wouldn't those people who need to refer to the manual be exactly the SF>>same people we wanted to protect from goto in the first place? :) OK, make it: goto: you don't really want to use it, but if you are still curious, see "jump".
-- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/ +972-3-6139665 ext.115

Bart de Boer

20 years ago
Steph Fox wrote:
>> BdB>>Even though I like "jump", people will most likely be searching for >> BdB>>"goto" (PHP manual) or "goto PHP" (Google) when they're trying to >> BdB>>find out if PHP has such a functionality. So, maybe it's better to >> BdB>>just call it "goto". >> >> For such people we might have a page in the manual saying: >> goto: see jump > > Erm, wouldn't those people who need to refer to the manual be exactly > the same people we wanted to protect from goto in the first place? :) > > jump +1, if it counts > > - Steph
If someone is searching for "goto" he/she most likely knows what he/she is looking for. So this also helps experienced developers who are new to PHP.

Steph

20 years ago
> If someone is searching for "goto" he/she most likely knows what he/she > is looking for. So this also helps experienced developers who are new to > PHP.
An experienced developer would know how to use it...! That was kind of the point. - Steph

Wez Furlong

20 years ago
or "goto: goto jump" On 3/9/06, Stanislav Malyshev <stas@zend.com> wrote:

Pierre Joye

20 years ago
On Thu, 9 Mar 2006 11:03:48 +0300 dmitry@zend.com ("Dmitry Stogov") wrote:
> Hi, > > The solution (2) - "goto only" is the winner. > So in case of no serious objections, I'll commit the "goto.diff" > patch in 24 hour. > > The last question: > What do you thin about Andi's solution about using "jump" instead of > "goto"? > > It may make sense, because it is not a full analog of C's goto > statement. It is a limited "goto". It allows jump back and forward, > but not INTO loops and switch statements.
+1 to commit the damned thing as it was proposed, goto (2). Everyone will look at goto, not jump (unless you use asm and then you need jmp :) --Pierre

Wez Furlong

20 years ago
My vote is +1 for goto, just because that largely describes what it does and how it is used. I don't mind if it winds up being called jump, I just think it will be easier for people to find it when they need it if it is called 'goto'. 'goto' also comes with all the usual anti-goto propaganda that will help discourage people that shouldn't be using it from using it. --Wez. On 3/9/06, Dmitry Stogov <dmitry@zend.com> wrote:

Bart de Boer

20 years ago
+1 for goto -1 for jump Wez Furlong wrote:

Marcus Börger

20 years ago
Hello Wez, just to continue on this nice argument: Jump reminds me of the worst addition to c ever: longjump. marcus Friday, March 10, 2006, 2:36:56 PM, you wrote:
> My vote is +1 for goto, just because that largely describes what it > does and how it is used. I don't mind if it winds up being called > jump, I just think it will be easier for people to find it when they > need it if it is called 'goto'. 'goto' also comes with all the usual > anti-goto propaganda that will help discourage people that shouldn't > be using it from using it.
> --Wez.
> On 3/9/06, Dmitry Stogov <dmitry@zend.com> wrote: >> Hi, >> >> The solution (2) - "goto only" is the winner. >> So in case of no serious objections, I'll commit the "goto.diff" patch in 24 >> hour. >> >> The last question: >> What do you thin about Andi's solution about using "jump" instead of "goto"? >> >> It may make sense, because it is not a full analog of C's goto statement. It >> is a limited "goto". It allows jump back and forward, but not INTO loops and >> switch statements. >> >> Thanks. Dmitry. >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >>
Best regards, Marcus

Dmitry Stogov

20 years ago
We already have exceptions, so we don't need another longjump :) "jump" or "goto"? Just make common decision and I will change it. Thanks. Dmitry.

Marcus Börger

20 years ago
Hello Dmitry, my advice just like Wez' is to name it 'goto' because that is what it is. (to drop the 2nd part that might have confused you). best regards marcus p.s.: To make me happy you'd have to drop the mess Sunday, March 12, 2006, 10:44:19 AM, you wrote:

Andi Gutmans

20 years ago
I'm fine with goto too. At 02:40 AM 3/12/2006, Marcus Boerger wrote:

Lukas Smith

20 years ago
Dmitry Stogov wrote:
> We already have exceptions, so we don't need another longjump :) > > "jump" or "goto"? Just make common decision and I will change it.
Dmitry, maybe I have overlooked a single post, but I have yet to see a single post favoring "jump" over "goto". The common decision is here and it is "goto". regards, Lukas

Steph

20 years ago
> Dmitry, maybe I have overlooked a single post, but I have yet to see a > single post favoring "jump" over "goto". The common decision is here and > it is "goto".
Lukas, that's extremely odd. Check history! (when most of the core team agreed on jump originally, for a start). I've seen five very vocal pro 'goto's here and NO good reasons given for it. There are several good reasons against. - Steph

Pierre Joye

20 years ago
On 3/12/06, Steph Fox <steph@zend.com> wrote:
> Lukas, that's extremely odd. Check history! (when most of the core team > agreed on jump originally, for a start). I've seen five very vocal pro > 'goto's here and NO good reasons given for it. There are several good > reasons against.
The result of the vote in this thread is clear. No matter what your history says, I think it is time to commit it and move to more interesting topic. --Pierre

Ilia A.

20 years ago
Let's just call it goto and be done with it. It seems that for the people who will use this feature "goto" name will cause the least amount of "WTF". Ilia

Dmitry Stogov

20 years ago
Seems the majority prefers "goto". I'll change "jump" to "goto" tomorrow in case of no serious objections. Thanks. Dmitry.

Xuefer Tinys

20 years ago
On 3/9/06, Steph Fox <steph@zend.com> wrote: > Please, Xuefer! Your vote was already recorded, shhh! i wasn't to vote more than once. it's same vote but with a bit different syntax changed. oh well, the result is out, this is only my explaination.