Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59333 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18052 invoked from network); 2 Apr 2012 22:43:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Apr 2012 22:43:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=charlie@charliesomerville.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=charlie@charliesomerville.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain charliesomerville.com from 74.125.82.54 cause and error) X-PHP-List-Original-Sender: charlie@charliesomerville.com X-Host-Fingerprint: 74.125.82.54 mail-wg0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:34169] helo=mail-wg0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 04/AC-43049-77B2A7F4 for ; Mon, 02 Apr 2012 18:43:03 -0400 Received: by wgbdq13 with SMTP id dq13so2585331wgb.11 for ; Mon, 02 Apr 2012 15:43:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-gm-message-state; bh=jpI8eudkDZrAETGUAe7OXBGoSPd736pbLIZ4OC8iwH8=; b=P4THwTfSYj5evpE4vDIzwdeg1CbEKEhegJDd8KNTROuzAGKZNwEbK/hwAUDERDhda5 UvCKDKtBRl+XwP6kj6K7zdI3QJOrJC6iseQdDx8TO02KnorA03Ul8Sj85guZOYLdkrQ7 Wk7yK131RLkTlxH7Y4N2tzt5zCyxKMIZ0gE/CvY5a+JSQg9x9DpgNXveT1YT/WKOAl70 832xye5wDG5sz19wUj6almZVTK5YW2/GLEN2ww5816uw9EK+CzJu9o9JlO01sUxYFMKV NxdWy/itfrz2o5SQyZPl3I+4cGDe5VRFD4iKfanrdm1pv83khtNDEXnqPcAfiOSh/nWv oWxw== MIME-Version: 1.0 Received: by 10.180.24.7 with SMTP id q7mr29920396wif.11.1333406580172; Mon, 02 Apr 2012 15:43:00 -0700 (PDT) Received: by 10.180.106.131 with HTTP; Mon, 2 Apr 2012 15:43:00 -0700 (PDT) Received: by 10.180.106.131 with HTTP; Mon, 2 Apr 2012 15:43:00 -0700 (PDT) In-Reply-To: References: Date: Tue, 3 Apr 2012 08:43:00 +1000 Message-ID: To: Rasmus Schultz Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=f46d043892ab8d66a004bcb9e9c4 X-Gm-Message-State: ALoCoQkFvkXE18EEHAcTvyv+gcdxRXoMUfYImC5ZEr2Rh9Sjiemmga917ONFIBlpidlWJyg/4eFa Subject: Re: [PHP-DEV] resume after exception From: charlie@charliesomerville.com (Charlie Somerville) --f46d043892ab8d66a004bcb9e9c4 Content-Type: text/plain; charset=UTF-8 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" 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? > --f46d043892ab8d66a004bcb9e9c4--