Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59323 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54374 invoked from network); 2 Apr 2012 12:44:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Apr 2012 12:44:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.213.170 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.213.170 mail-yx0-f170.google.com Received: from [209.85.213.170] ([209.85.213.170:52038] helo=mail-yx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 71/D1-43049-F1F997F4 for ; Mon, 02 Apr 2012 08:44:16 -0400 Received: by yenl5 with SMTP id l5so1259661yen.29 for ; Mon, 02 Apr 2012 05:44:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type :x-gm-message-state; bh=mRTgOSj2WfQyAT4VEb1R2H6IPpEJfUUgdkkYFRkVSyw=; b=Zele69AFkDFgcS42pijCPm1dq6p6pxbh/06BRLTteREQb/FTprPgLqP94enTy9OVCi +2K2R+CfClY3WRpTQ7ZQYLxCXjxfjkZp0TRD+WJt5CwxVNJyRnUIKUHVAoJily+50F3Y iNyRr7QCUI1o5F9NvUd++FForxYnyuwOMyIiu7U5ncFU25APoMWMgNppHfsxcBgXV15D d5H8QUw5+JuiKqg01Shxs07ZelYYMa+kzDmFi5Y2ww8bdh8qggnJVYdHQFpWWT+Fojo3 BCeI7A2Ll7HMjrBYmvbk/Yi815hTJS6MnNtLY3kemDEd/p7Td/S57JqpVg3uYJiGm3vD twcA== MIME-Version: 1.0 Received: by 10.60.20.3 with SMTP id j3mr12593131oee.43.1333370652253; Mon, 02 Apr 2012 05:44:12 -0700 (PDT) Received: by 10.60.57.2 with HTTP; Mon, 2 Apr 2012 05:44:12 -0700 (PDT) Date: Mon, 2 Apr 2012 08:44:12 -0400 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=e89a8fb2076214dd2704bcb18cd1 X-Gm-Message-State: ALoCoQkvcWLAg27nSHKK9dms0Y86Y3qBl6vKdmEQ7icnZBPfq3hfzTuVcbEbJ4D8E/6KcAJLXdiU Subject: resume after exception From: rasmus@mindplay.dk (Rasmus Schultz) --e89a8fb2076214dd2704bcb18cd1 Content-Type: text/plain; charset=ISO-8859-1 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? --e89a8fb2076214dd2704bcb18cd1--