ID: 50726 Comment by: kenaniah at gmail dot com Reported By: kenaniah at gmail dot com Status: Open Bug Type: Feature/Change Request Operating System: Linux PHP Version: 5.3.1 New Comment:
I agree that this may be abuse of exceptions. Essentially, I am looking for some sort of flow control system that allows me send messages, handle them, and yield control back to various points in the execution stack at my discretion. Previous Comments: ------------------------------------------------------------------------ [2010-01-12 00:16:31] degeb...@php.net An exception is by definition a state where the program no longer knows how to proceed. It's basically a way of saying "I give up, you'll have to handle this yourself". You have this ability using a try-catch block. Exceptions shouldn't be used to control the application flow, but should be used for genuinely exceptional situations. In my opinion, if a try-catch block doesn't satisfy your needs, you are more than likely misusing exceptions. ------------------------------------------------------------------------ [2010-01-11 23:53:02] kenaniah at gmail dot com Description: ------------ I think that PHP would benefit greatly by implementing a feature known as "resumeable" exceptions. The end goal would be to provide a method by which code execution may be continued from the point at which an exception was thrown. Naturally, some exceptions should not be resumeable by nature, which would require an extension to the Exception class of a simple boolean property indicating whether an instance of that exception can be resumed or not. The only real problem AFAICS with resumeable exceptions has to do with the state of the execution stack. Obviously, if execution were to be resumed after an exception is handled, the stack can not be unwound automatically (Schrodinger's cat, anyone?). My suggestion would be to allow another keyword besides "catch" (such as "resume") to handle exceptions. If a resumeable exception is thrown and caught in a "resume" block, the parser should proceed as if it were handling a function call. In short, the unwinding of the execution stack would need to be deferred until it is determined whether or not execution will be resumed at the point of the exception. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50726&edit=1