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:
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.

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

Reply via email to