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 */
?>
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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php