If just for exception recovery how about implement ruby's retry ?
http://www.tutorialspoint.com/ruby/ruby_loops.htm Ruby retry statement section.
在 2012年4月2日星期一,下午8:44,Rasmus Schultz 写道:
> I was just reading about the new async/await keywords in C# 5.0, and while
> this has no particular relevance to PHP as such, it got me thinking about
> this idea...
>
> What if you could resume execution after an exception was thrown?
>
> Fictive example:
>
> function test()
> {
> echo "Begin Test!\n";
>
> throw new Interrupt();
>
> echo "Execution resumed!";
> }
>
> try
> {
> test();
> }
> catch (Interrupt $e)
> {
> echo "Execution interrupted.\n";
> resume;
> }
>
> The output of this would be:
>
> Begin Test!
> Execution interrupted.
> Execution resumed!
>
> In other words, Interrupt is a new type of Exception, from which you can
> recover, using the new resume keyword.
>
> Taking this one step further, imagine it were also possible to serialize()
> an Interrupt - and resume it at a later time. This would open up entirely
> new possibilities for (AJAX) web-application frameworks, which would be
> able to suspend execution, serialize the script state, return a response,
> wait for further interaction from the user, and then resume execution.
>
> I'm sure there are lots of problems with this idea, and perhaps it's not a
> good fit for PHP at all, but I figured it couldn't harm to put the idea out
> there anyway :-)
>
> Any thoughts?