Re: Problems w/ goto

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Dec 17, 2010 at 10:05 AM, larry@xxxxxxxxxxxxxxxx <
larry@xxxxxxxxxxxxxxxx> 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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux