# GOTO replacement statements

- Thread: https://externals.io/message/20903
- Original archive: https://news-web.php.net/php.internals/20903
- Started by Tim Gales on 2005-11-30T17:23:20+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #20903 — Tim Gales — 2005-11-30T17:23:20+00:00

URL: https://externals.io/message/20903#20903

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

---

## #20904 — Stanislav Malyshev — 2005-11-30T17:27:12+00:00

URL: https://externals.io/message/20903#20904 · In reply to: #20903

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
