GOTO replacement statements

php.internals

Tim Gales

20 years ago
I was wondering if it would be worthwhile to consider replacing the functionality of a 'goto' statement with two or maybe three statements. 'break_to' 'advance_to' and maybe even 'change_state_to' while($foo1) as LABEL1 { .... while($foo2) { ... if($var1) break; if($var2) break_to LABEL1; ... if($var3) advance_to LABEL2; ... .. } LABEL2: 'break_to' might make it easier for someone who has to review/maintain the code to spot it as a 'goto' replacement to break out of a nested loop. 'advance_to' would hopefully cut down on the number of bug reports claiming that 'jump' doesn't work properly (when trying to go backwards) Regards, Tim Gales

Stanislav Malyshev

20 years ago
TG>>replacing the functionality of a 'goto' statement with TG>>two or maybe three statements. TG>> TG>>'break_to' 'advance_to' and maybe even 'change_state_to' And maybe even to please_change_current_executing_opcode_number_to_the_opcode_that_corresponds_to_label after all, we don't want to have any place for misunderstaning and we definitely don't want to be rude... If we want to limit it to forward-jump, we might add also _but_only_if_it_does_not_mean_jumping_backwards. Then nobody would say it is not intuitive, at least.
-- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/ +972-3-6139665 ext.115