Stanislav Malyshev wrote:
Exceptions are structured way of handling code flow - you can not get to random points of code with exception, you can get either to enclosing catch or stop the program entirely. Unlike exceptions, goto allows to jump to a random point of code.

a small objection here: with a GOTO it is clear where execution continues,
you can simply search for the label the GOTO is using. With exceptions on
the other hand it is way harder to find out where it is actually going to
be handled: could be the next catch() or not, even one in a different
function or method upstream on the call stack, or maybe it isn't even
caught at all but producing a runtime exception error instead ...

so using goto and lables can actually be *more* clean ...

I don't know what do you mean by "limited" - I see that the consensus among the goto proponents is to not impose any limits on the place you could jump to - because, of course, once you strated to jump around you always can find a use for jumping to any place, if you are creative enough - and I do not doubt creativity of PHP people.

i think we all agreed ons *some* limits on GOTO that nobody ever put
in question:

- can only jump out of a block, not into
- can not jump out of a function body (unlike exceptions)

jumping back and forth instead of just forward is needed for state
machine implementations, the alternatives (abusing switch(), having
a seperate function for each state which are called by name ...)
are way less clean

if we are retricting GOTO to just jump forward we might be better off
with named loops and labeled breaks just as in java, there is not
much extra use in being able to place the labels anywhere you want
then ...


--
Hartmut Holzgraefe, Senior Support Engineer                            .
MySQL AB, www.mysql.com

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to