php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50726 Resume after Exceptions
Submitted: 2010-01-11 23:53 UTC Modified: 2010-11-24 09:54 UTC
Votes:4
Avg. Score:4.0 ± 1.7
Reproduced:2 of 3 (66.7%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: kenaniah at gmail dot com Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 5.3.1 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kenaniah at gmail dot com
New email:
PHP Version: OS:

 

 [2010-01-11 23:53 UTC] 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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-12 00:16 UTC] degeberg@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-12 00:48 UTC] kenaniah at gmail dot com
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.
 [2010-11-24 09:54 UTC] jani@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2010-11-24 09:54 UTC] jani@php.net
-Package: *General Issues +Package: Scripting Engine problem
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 23:01:26 2024 UTC