Magnus Holm has an excellent proof of concept for this in Ruby, which supports continuations:
http://timelessrepo.com/never-gonna-let-you-go On Apr 2, 2012 10:44 PM, "Rasmus Schultz" <ras...@mindplay.dk> wrote: > 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? >