Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67176 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34189 invoked from network); 26 Apr 2013 19:40:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Apr 2013 19:40:00 -0000 Authentication-Results: pb1.pair.com header.from=rstoll@tutteli.ch; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rstoll@tutteli.ch; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain tutteli.ch designates 80.74.154.78 as permitted sender) X-PHP-List-Original-Sender: rstoll@tutteli.ch X-Host-Fingerprint: 80.74.154.78 ns73.kreativmedia.ch Linux 2.6 Received: from [80.74.154.78] ([80.74.154.78:47501] helo=hyperion.kreativmedia.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 23/98-15719-D08DA715 for ; Fri, 26 Apr 2013 15:39:58 -0400 Received: (qmail 3131 invoked from network); 26 Apr 2013 21:39:54 +0200 Received: from ip-31-205-11-203.ask4internet.com (HELO RoLaptop) (31.205.11.203) by ns73.kreativmedia.ch with (AES128-SHA encrypted) SMTP; 26 Apr 2013 21:39:54 +0200 Cc: "'PHP Internals'" References: <517AD23A.7010505@heigl.org> In-Reply-To: <517AD23A.7010505@heigl.org> Date: Fri, 26 Apr 2013 20:39:51 +0100 Message-ID: <003e01ce42b5$d2503a30$76f0ae90$@tutteli.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQG3O73jjKy861OdQIbwQgwza2r8tgHDGO2SmQjY0RA= Content-Language: de-ch Subject: AW: [PHP-DEV] Continued try blocks From: rstoll@tutteli.ch ("Robert Stoll") I like the idea but would prefer another control structure such as CreateTryCatchBlockForEverySingleLine (should be shorter though) rather = than continue. The continue keyword is confusing in my opinion. And I would say it = should be for every single statement whereupon a statement is defined by either = ; or {} rather then for every single line. Thus the following code: tryStatements{ $a =3D foo(); if($a > 1){ $i =3D bar(); }else{ $i =3D muu(); } for(;$i<10;$i++){ //.. } }catch(Exception $ex){ log($ex); } Would result in: try{ $a =3D foo(); } catch(Exception $ex){ log($ex); } try{ if($a > 1){ $i =3D bar(); }else{ $i =3D muu(); } } catch(Exception $ex){ log($ex); } try{ for(;$i<10;$i++){ //.. } } catch(Exception $ex){ log($ex); } -----Urspr=FCngliche Nachricht----- Von: Andreas Heigl [mailto:andreas@heigl.org]=20 Gesendet: Freitag, 26. April 2013 20:15 An: Julien Pauli Cc: PHP Internals Betreff: Re: [PHP-DEV] Continued try blocks Am 26.04.13 16:41, schrieb Julien Pauli: > Hello internals, >=20 > I had an idea recently with a friend, about a feature try-catch blocks > could use. > Let me just write an example, you will quickly understand the idea : >=20 > * * > * > *try {* > * foo();* > * bar();* > * baz();* > *} catch (SomeException $e) {* > * dosomestuff();* > * continue; /* Here is the feature, go back to try block */* > *} catch (Exception $e) {* > * dosomething();* > *}* >=20 >=20 >=20 > The continue keyword would resume the execution from where it had > diverged, according to the function which led to the SomeException > catch block. >=20 > So, in this example, if, say, bar() throws a SomeException , the code > would then resume and execute baz() after the catch block. >=20 > Just presenting the idea here, no RFC actually , I'm collecting > thoughts and notices. >=20 > Julien.Pauli >=20 Hi Julien. What about the following example? try { $foo =3D $bar->getObject(); $foo->doSomething() } catch(Exception $e) { continue // Or whatever shall be used } When $bar->getObject throws an Exception no $foo is set. So the next line will result in a "PHP Fatal error: Call to a member function doSomething() on a non-object". So where shall the "continue" actually continue? In the line after the exception was thrown? In the line following the last line $foo was accessed in? Or would something like CreateTryCatchBlockForEverySingleLine { $bar->doOne(); $bar->doNext(); $bar->doSomethingElse(); } catch(Exception $e) { doSomethingWithTheException($e); } resulting in try { $bar->doOne(); } catch(Exception $e) { doSomethingWithTheException($e); } try { $bar->doNext(); } catch(Exception $e) { doSomethingWithTheException($e); } try { $bar->doSomethingElse(); } catch(Exception $e) { doSomethingWithTheException($e); } be more what you are talking about? Regards Andreas --=20 ,,, (o o) +---------------------------------------------------------ooO-(_)-Ooo-+ | Andreas Heigl | | mailto:andreas@heigl.org N 50=B022'59.5" E = 08=B023'58" | | http://andreas.heigl.org http://hei.gl/wiFKy7 | +---------------------------------------------------------------------+ | http://hei.gl/root-ca | +---------------------------------------------------------------------+