Re: PHP 5.1
| From: | Stanislav Malyshev | Date: | Mon, 06 Jun 2005 14:20:28 +0000 |
| Subject: | Re: PHP 5.1 | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-16439@lists.php.net to get a copy of this message | ||
LS>>the safe guard is that you only have:
LS>># static labels to jump to
That's not a safeguard, since you still can jump to any label.
LS>># that you can only jump in the current scope
This is a safeguard, buit not enough of that, since you still can jump
into various control blocks.
LS>>now tell me that exceptions dont allow for much more drastic jumps in your
LS>>code that will not be able to easily be detected (in most cases with a
LS>>simple search in your current file)
No, they do not. You can not exception to abritrary point of the code. You
can go either to the end of the function or to the end of the try block.
That's the whole difference - you can't just go to random place in the
code, you have to maintain structure. With goto, you can jump into random
blocks of code - some of which make certain assumprions about the
environment, like foreach, switch, catch and maybe more. So either you
have severly limit goto (to the point it's more like break in Perl - with
which concept I could live) - or have a lot of weird troubles.
LS>>and again if all you want to do is a single jump, why on earth would
LS>>you want people to be forced to throw an exception, which they have no
LS>>intention of using.
Because you usually don't want "single jump" - you want cleanup after
resource allocation or something like that. try/catch may not be the only
solution for every case in existance - I just was surprised by the claim
that excepctions are worse than other methods.
--
Stanislav Malyshev, Zend Products Engineer
stas@zend.com http://www.zend.com/ +972-3-6139665 ext.115