Re: Re: GOTO and/or BREAK LABEL
From: Sara Golemon Date: Tue, 07 Mar 2006 18:48:00 +0000 Subject: Re: Re: GOTO and/or BREAK LABEL References: 1 2 Groups: php.internals Request: Send a blank email to [email protected] to get a copy of this message
label_a: $i=0; label_b: $i++; while($i<10) {break/continue label only works when the label IMMEDIATELY preceeds the loop construct thus saying "I identify this loop atif(foo()) continue label_b; else { if(bar($i++)) goto label_a; }} And that would be a parse error.label_foo
". Here's another reason for break being distinct from goto: foo: foreach($arr as $val) { if (cond1) break foo; /* Leave the loop entirely */ if (cond2) continue foo; /* Jump to next itteration in loop */ if (cond3) goto foo; /* Restart the loop from the beginning */ } Each type of label-targeted statement does a different thing. But if that is ((really)) is confusing then you're right, it's not a good thing. break 1;/continue 1; would cover the first two conditions in that example just fine. To me, I see more consistency in working on the foo loop with foo on all statements. -Sara Still +1 goto, +0 goto with labeled breaks.
Thread (106 messages)
« previous | php.internals (#22221) | next » |
---|