Re: Re: Labeled Breaks (not the G-word)
| From: | Jochem Maas | Date: | Tue, 29 Nov 2005 15:12:18 +0000 |
| Subject: | Re: Re: Labeled Breaks (not the G-word) | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-20828@lists.php.net to get a copy of this message | ||
Stanislav Malyshev wrote:
EK>>This might be from implementation/engine point of view, but from user's EK>>perspective goto is much more limited. It can only happen within one EK>>function. That's good. PHP is a limited language - you can not do many things in PHP that you can do in C, for example. Many of these things usually are called "bugs" when people do them :) EK>>Exception on the other hand might take code execution into totally EK>>different file which is why I guess it feels much less restricted that goto. Exceptions never should be used "to take execution into different file".unless I define every class, function and all 'main' code in one file then I don't see how one can avoid exceptions 'moving executions into different files' when an exception occurs. a function myExample() inits an object and calls a method, which does some stuff amongst other things calling another objects method that happens to throw an exception... the originally called myExample() function (defined in a different file to the code that calls the function) catches the Exception. the exception has 'travelled' through 3 files from throw to catch and the code that triggered that whole shebang is in a 4th file... I can't see how to avoid such situation without resorting to not using exceptions (given that certain extensions may throw them and that the engine itself will [be able to] increasingly in the future, thats not much of an option) probably I'm still misunderstanding exceptions... rgds, Jochem
That's not their purpose and if you plan to use them with this intention - don't. Exceptions are meant for the thrower - to signal that situation does not allow for the current function to continue execution and for the catcher - to deal with the exceptional situation respectively. It's purpose is to handle exceptional situation, not to pass control around - which is exactly the purpose of goto. And the reason why I don't like it.