Re: Problems w/ goto
| From: | David Harkness | Date: | Mon, 20 Dec 2010 21:47:17 +0000 |
| Subject: | Re: Problems w/ goto | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-310162@lists.php.net to get a copy of this message | ||
On Fri, Dec 17, 2010 at 10:05 AM, larry@garfieldtech.com <
larry@garfieldtech.com> wrote:
> What PHP has implemented is "named break statements", as I understand it.
>
Not exactly. You can jump to arbitrary (labeled) lines within the same
context (method/function), but you cannot enter loop constructs--only exit
them. While the last bit implies they are only "named break statements," you
can use them outside of loops as a normal goto statement.
firingSequence:
if (!acquireTarget())
goto done;
fireMainCannon();
fireMissiles();
if (enemiesInView()):
goto firingSequence;
done:
The above implements a convoluted do...while loop using goto. Recommended?
Certainly not!
David