Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » PHP
  • » [PHP-DEV] Re: Labeled Break (nothing at all whatsoever to do with GOTO) [RSS Feed]

#1 Nov. 30, 2005 09:11:20

Bart d.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Re: Labeled Break (nothing at all whatsoever to do with GOTO)


Sara++ :)Although I prefer BAR:while (This would go better with goto if someonewould want to implement that some day.) I'd settle for while BAR since Idon'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: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.diffUsage:

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

Offline

#2 Nov. 30, 2005 09:25:07

Ron K.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Re: Labeled Break (nothing at all whatsoever to do with GOTO)


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" <> schreef in bericht

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

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#3 Nov. 30, 2005 09:46:07

Bart d.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Re: Labeled Break (nothing at all whatsoever to do with GOTO)


I wasn't thinking about goto or break. I was thinking about *labels* andusing 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: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 futuregoto-implementation, because that would mean it would jump to the beginningof the loop, and not out of the loop. Maybe you mean to say that labels forgoto and break can exist in the same collection, but I wouldn't be a fan ofthat at all.Semantically, 'goto' behavior is very different from break-behavior. With abreak I expect to leave a certain construct that has a certain name, withgoto I expect to jump to the line of code that was labeled with a name. Ithink the usage is different enough not to want those labels to be the samekind of things. Maybe other people disagree, but my point is that thedifference in semantics is really something to consider.--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

  • Root
  • » PHP
  • » [PHP-DEV] Re: Labeled Break (nothing at all whatsoever to do with GOTO) [RSS Feed]

Board footer

Moderator control

Enjoy the 22nd of April
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support