# GOTO and/or BREAK LABEL

- Thread: https://externals.io/message/22174
- Original archive: https://news-web.php.net/php.internals/22174
- Started by Dmitry Stogov on 2006-03-07T09:28:27+00:00
- Messages: 54
- Page 1 of 3: messages 1 to 25 (25 per page, add `?page=N` to the URL)
- Next page: https://externals.io/message/22174.md?page=2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #22174 — Dmitry Stogov — 2006-03-07T09:28:27+00:00

URL: https://externals.io/message/22174#22174

Hi,

Because of some confused people I reverted "break label" patch and post it
for discussion once again together with GOTO patch.

Please reviw and vote.

1) goto and break label
2) goto only (like C)
3) break label only (like Java)
4) nothing

My vote: (1) +0.5, (4) +0.5

Thanks. Dmitry.

---

## #22175 — Sascha Schumann — 2006-03-07T09:33:08+00:00

URL: https://externals.io/message/22174#22175 · In reply to: #22174

> Hi,
> 
> Because of some confused people I reverted "break label" patch and post it
> for discussion once again together with GOTO patch.
> 
> Please reviw and vote.
> 
> 1) goto and break label
> 2) goto only (like C)
> 3) break label only (like Java)
> 4) nothing

    5) goto, fowarding-jumping only.

    - Sascha

---

## #22176 — Edin Kadribasic — 2006-03-07T09:37:47+00:00

URL: https://externals.io/message/22174#22176 · In reply to: #22174

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) +1

Edin

---

## #22177 — Michael Wallner — 2006-03-07T09:44:16+00:00

URL: https://externals.io/message/22174#22177 · In reply to: #22174

Dmitry Stogov wrote:

> 1) goto and break label
+0

> 3) break label only (like Java)
+1

Regards,
-- 
Michael - <mike(@)php.net> http://dev.iworks.at/ext-http/http-functions.html.gz

---

## #22178 — Stanislav Malyshev — 2006-03-07T09:44:54+00:00

URL: https://externals.io/message/22174#22178 · In reply to: #22174

DS>>1) goto and break label
DS>>2) goto only (like C)
DS>>3) break label only (like Java)
DS>>4) nothing

1) +0.5 2) -1 3) +1 

-- 
Stanislav Malyshev, Zend Products Engineer
stas@zend.com  http://www.zend.com/ +972-3-6139665 ext.115

---

## #22179 — Rasmus Lerdorf — 2006-03-07T09:48:16+00:00

URL: https://externals.io/message/22174#22179 · In reply to: #22177

Michael Wallner wrote:
> Dmitry Stogov wrote:
> 
> > […]
> +0
> 
> > […]
> +1

You do realize that this is:

   label:
   while(condition) {
     break label;
   }

As a C programmer this confuses me to no end.  When I see "label:" I 
expect control to end up there and the loop to be executed again.  I 
realize all the Java folks have gotten used to this, but I don't think I 
ever will.

-Rasmus

---

## #22180 — Michael Wallner — 2006-03-07T09:56:23+00:00

URL: https://externals.io/message/22174#22180 · In reply to: #22179

Rasmus Lerdorf wrote:
> Michael Wallner wrote:
> 
> > […]
> 
> 
> You do realize that this is:
> 
>   label:
>   while(condition) {
>     break label;
>   }
> 
> As a C programmer this confuses me to no end.  When I see "label:" I 
> expect control to end up there and the loop to be executed again.  I 
> realize all the Java folks have gotten used to this, but I don't think I 
> ever will.

Yes, but it's quite obvious to me if I replace the labeled break with `break 1;`
I'd expect `continue label;` to step into the loop again.

By the way, +0 does not mean -1 for goto.

Regards,
-- 
Michael - <mike(@)php.net> http://dev.iworks.at/ext-http/http-functions.html.gz

---

## #22181 — Stanislav Malyshev — 2006-03-07T09:57:29+00:00

URL: https://externals.io/message/22174#22181 · In reply to: #22179

RL>>As a C programmer this confuses me to no end.  When I see "label:" I expect

The question is should all languages be like C? So, C has it that way, and 
Java and Perl have it other way. We don't move to prefix notation because 
Forth has it ;)

-- 
Stanislav Malyshev, Zend Products Engineer
stas@zend.com  http://www.zend.com/ +972-3-6139665 ext.115

---

## #22183 — Antony Dovgal — 2006-03-07T10:01:38+00:00

URL: https://externals.io/message/22174#22183 · In reply to: #22174

> Hi,
> 
> Because of some confused people I reverted "break label" patch and post it
> for discussion once again together with GOTO patch.
> 
> Please reviw and vote.
> 
> 1) goto and break label
> 2) goto only (like C)
> 3) break label only (like Java)
> 4) nothing

2) +0.5
4) +0.5

-- 
Wbr, 
Antony Dovgal

---

## #22182 — Derick Rethans — 2006-03-07T10:06:27+00:00

URL: https://externals.io/message/22174#22182 · In reply to: #22175

> 
> 
> > […]
> 
>     5) goto, fowarding-jumping only.

Yes I agree with that if you mean by forwarding: down and out of scope 
only (not into loop constructs). I would assume you mean that though.

Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #22184 — Derick Rethans — 2006-03-07T10:07:35+00:00

URL: https://externals.io/message/22174#22184 · In reply to: #22179

> Michael Wallner wrote:
> > […]
> 
> You do realize that this is:
> 
>   label:
>   while(condition) {
>    break label;
>   }
> 
> As a C programmer this confuses me to no end.  When I see "label:" I expect
> control to end up there and the loop to be executed again.  I realize all the
> Java folks have gotten used to this, but I don't think I ever will.

Nor would I... this is a "NONO" for me.

Derick

---

## #22189 — Wez Furlong — 2006-03-07T12:46:47+00:00

URL: https://externals.io/message/22174#22189 · In reply to: #22174

> 1) goto and break label
+1

I'm happy with goto, but don't mind getting labelled breaks "for
free"; labels are better than numbers.

> 2) goto only (like C)
+1

> 3) break label only (like Java)
+0.5, but only if we don't have goto

--Wez.

---

## #22190 — Pierre — 2006-03-07T12:52:49+00:00

URL: https://externals.io/message/22174#22190 · In reply to: #22189

> 
> > […]
> +1
>
> I'm happy with goto, but don't mind getting labelled breaks "for
> free"; labels are better than numbers.

same here +1

> > […]
+1

> > […]
> +0.5, but only if we don't have goto

+0

--Pierre

---

## #22191 — Zeev Suraski — 2006-03-07T13:00:52+00:00

URL: https://externals.io/message/22174#22191 · In reply to: #22174

At 11:28 07/03/2006, Dmitry Stogov wrote:
>Hi,
>
>Because of some confused people I reverted "break label" patch and post it
>for discussion once again together with GOTO patch.
>
>Please reviw and vote.
>
>1) goto and break label
>2) goto only (like C)
>3) break label only (like Java)
>4) nothing
>
>My vote: (1) +0.5, (4) +0.5

(3) +0.5
(4) +1

---

## #22192 — Xuefer — 2006-03-07T13:02:01+00:00

URL: https://externals.io/message/22174#22192 · In reply to: #22174

> Hi,
>
> Because of some confused people I reverted "break label" patch and post it
> for discussion once again together with GOTO patch.
>
> Please reviw and vote.
>
> 1) goto and break label
> 2) goto only (like C)
> 3) break label only (like Java)
> 4) nothing
>
thanks for this thread.
+0.5 for goto
+1 for "do { break label; } while(0); label:" (line label, same with goto)
or if the above is not acceptable, +0.5 for java like "label: do {
break label; } while(0);" (block label, confusing with goto)

---

## #22196 — Hartmut Holzgraefe — 2006-03-07T14:18:20+00:00

URL: https://externals.io/message/22174#22196 · In reply to: #22175

Sascha Schumann wrote:
>     5) goto, fowarding-jumping only.

which would more or less make it useless for state machine stuff, right?

-- 
Hartmut Holzgraefe, Senior Support Engineer                            .
MySQL AB, www.mysql.com

Join me at MySQL's 2006 Users Conference, April 24-27!
http://www.mysqluc.com/

---

## #22197 — Ilia Alshanetsky — 2006-03-07T14:36:35+00:00

URL: https://externals.io/message/22174#22197 · In reply to: #22174

Dmitry Stogov wrote:
> 1) goto and break label

+1

> 2) goto only (like C)

+1

> 3) break label only (like Java)

-1

Ilia

---

## #22199 — Steph Fox — 2006-03-07T14:44:34+00:00

URL: https://externals.io/message/22174#22199 · In reply to: #22174

> 1) goto and break label
> 2) goto only (like C)
> 3) break label only (like Java)
> 4) nothing

Thanks for giving this a final chance, Dmitry.

1) +0.5 
3) +1 

- Steph

---

## #22200 — Greg Beaver — 2006-03-07T15:10:39+00:00

URL: https://externals.io/message/22174#22200 · In reply to: #22174

Dmitry Stogov wrote:
> Hi,
> 
> Because of some confused people I reverted "break label" patch and post it
> for discussion once again together with GOTO patch.
> 
> Please reviw and vote.
> 
> 1) goto and break label
> 2) goto only (like C)
> 3) break label only (like Java)
> 4) nothing

For what it is worth:

1) +0.5
2) +1
3) +0
4) -1

I don't see any real benefit to break label as the deepest I have ever
seen is 3 levels of break.  I have run up against too many situations
where the only way to lex something effectively in PHP is with pcre.
The ability to port a tool like re2c would make it far easier to do
things efficiently without having to write a new PHP extension.  I doubt
any users will suddenly start peppering goto all over their source, I
just can't see that happening when there are so many other great loop
constructs available.  Discouraging its use is easy - just make sure the
manual makes it really unattractive and has examples of better ways to
implement goto using for/foreach/while.

Greg

---

## #22201 — Andi Gutmans — 2006-03-07T15:15:31+00:00

URL: https://externals.io/message/22174#22201 · In reply to: #22174

I'm with Rasmus on the break label stuff. Although it's not confusing 
to me, I got convinced quickly that it'll be confusing to the wider 
audience. So big -1 from me for (2) & (1).

I think we should either stick with nothing or go to a full goto 
(without jumping into scopes of course). Only forward gotos would go 
against one of the main initial motivations for discussing this which 
was state machines.

I suggest we apply this and allow people to play around with it/test it....

Btw, how about naming it "jump" and not "goto"? :)
Andi

At 01:28 AM 3/7/2006, Dmitry Stogov wrote:
>Hi,
>
>Because of some confused people I reverted "break label" patch and post it
>for discussion once again together with GOTO patch.
>
>Please reviw and vote.
>
>1) goto and break label
>2) goto only (like C)
>3) break label only (like Java)
>4) nothing
>
>My vote: (1) +0.5, (4) +0.5
>
>Thanks. Dmitry.

---

## #22204 — Edin Kadribasic — 2006-03-07T15:28:48+00:00

URL: https://externals.io/message/22174#22204 · In reply to: #22201

Andi Gutmans wrote:
> I'm with Rasmus on the break label stuff. Although it's not confusing to
> me, I got convinced quickly that it'll be confusing to the wider
> audience. So big -1 from me for (2) & (1).

From your comment bellow I figure you're for option 2, right?

Edin


> I think we should either stick with nothing or go to a full goto
> (without jumping into scopes of course). Only forward gotos would go
> against one of the main initial motivations for discussing this which
> was state machines.
> 
> I suggest we apply this and allow people to play around with it/test it....
> 
> Btw, how about naming it "jump" and not "goto"? :)
> Andi
> 
> At 01:28 AM 3/7/2006, Dmitry Stogov wrote:
> 
> > […]

---

## #22205 — Andi Gutmans — 2006-03-07T15:30:37+00:00

URL: https://externals.io/message/22174#22205 · In reply to: #22204

Yes 2. Sorrry

At 07:28 AM 3/7/2006, Edin Kadribasic wrote:
>Andi Gutmans wrote:
> > […]
>
> > […]
>
>Edin
>
>
> > […]

---

## #22206 — Rob Richards — 2006-03-07T16:00:55+00:00

URL: https://externals.io/message/22174#22206 · In reply to: #22174

Dmitry Stogov wrote:
> 1) goto and break label
>   
+0.5
> 2) goto only (like C)
>   
+1
> 3) break label only (like Java)
>   
-1

Rob

---

## #22207 — Rasmus Lerdorf — 2006-03-07T16:09:02+00:00

URL: https://externals.io/message/22174#22207 · In reply to: #22181

Stanislav Malyshev wrote:
> RL>>As a C programmer this confuses me to no end.  When I see "label:" I expect
> 
> The question is should all languages be like C? So, C has it that way, and 
> Java and Perl have it other way. We don't move to prefix notation because 
> Forth has it ;)

No, obviously all languages shouldn't be like C and PHP has plenty of 
stuff that looks nothing like C, but like it or not, a lot of PHP's 
syntax came from C and I don't think we should be adding syntax that 
looks like something from C but doesn't act like it.

I still think this is a really fringe feature that isn't worth one of 
the first forward compatibility breaks in the procedural language in years.

-Rasmus

---

## #22209 — Sara Golemon — 2006-03-07T16:43:34+00:00

URL: https://externals.io/message/22174#22209 · In reply to: #22174

> 1) goto and break label
+0
Making goto's labels work with break is cheap, but less vital than goto.

> 2) goto only (like C)
+1
Within scope and out of break context is a given.  My preference is to not
limit jumping to forward only, though such a limit would still be a step in
the right direction.

> 3) break label only (like Java)
0
See #1

> 4) nothing
-1

---

Next page: https://externals.io/message/22174.md?page=2
