Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61742 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65180 invoked from network); 25 Jul 2012 07:22:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jul 2012 07:22:30 -0000 Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vb0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:50517] helo=mail-vb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B3/6C-27263-4BE9F005 for ; Wed, 25 Jul 2012 03:22:29 -0400 Received: by vbbfs19 with SMTP id fs19so350355vbb.29 for ; Wed, 25 Jul 2012 00:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=ZLzgMMX8pi16QAMIHJ/lllKvM63PhS1mB4qxmqZw7Bw=; b=UOojymDsNlLXNABVcYQVHS0rmthpqXX5EpNnbzI+bcYjqdDLcqi2CZ27RBUA97vasY q/786Rg50bvfHVKlWzxL0Bdb0eKJj8RuAoJ7YdXAz5vv4Da8HMQHYaVi//DyL6uOBdWG DGXAUGp+aVjKyVWbvwFclVJQM3zGLphPOjpcIX7h5jAA4FRba0Jqsmv1i0+/f6wwDGuF tLtvLbTC38XQwAHJLAA2nETd6gyWbO4lARpCK9tpcHHNmecrohn89Z2mF97rQmjDX/UY aj14DVjzqSX0MdA1QkftlHJo74VXITRgD+CF0J+hPdDI5uprFbGcF+6OUhRvuVagYrJn WPLA== Received: by 10.52.21.177 with SMTP id w17mr15121478vde.98.1343200945615; Wed, 25 Jul 2012 00:22:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.195.3 with HTTP; Wed, 25 Jul 2012 00:22:05 -0700 (PDT) In-Reply-To: References: <4B17D4B8-B310-4173-A0F2-C6514E7995BA@gmail.com> <-6650565022729239946@unknownmsgid> Date: Wed, 25 Jul 2012 15:22:05 +0800 Message-ID: To: Galen Wright-Watson Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Supports 'finally' keyword for PHP exceptions From: laruence@gmail.com (Xinchen Hui) On Wed, Jul 25, 2012 at 3:23 AM, Galen Wright-Watson w= rote: > > > On Tue, Jul 24, 2012 at 5:03 AM, Xinchen Hui wrote: >> >> Sent from my iPhone >> >> =E5=9C=A8 2012-7-24=EF=BC=8C19:51=EF=BC=8CRafael Kassner =E5=86=99=E9=81=93=EF=BC=9A >>> >>> >>> Thanks Laruence. >>> If I perform something like this: >>> function test() { >>> try { >>> return 2; >>> } catch (Exception $e) { >>> } finally { >>> return 3; >>> } >>> } > > > Reminds me of nerd sniping at Google > (http://neil.fraser.name/news/2009/10/27/, bottom of the page). > > Worse example: > > $r =3D 1; > try { > return $r; > } catch (Exception $e) { > } finally { > $r =3D 2; > } > >>> >>> What will be returned? There is no possibility to return something in >>> finally, or finally will overwrite the return? >> >> >> overweite=EF=BC=8Calthough I think it make no sense return in finally bl= ock >> >> But seems java allow that, so I implement it > > > C# has perhaps more desirable behavior > (http://blogs.msdn.com/b/jmstall/archive/2006/10/05/finally_5f00_vs_5f00_= return.aspx): > a return in a finally block is illegal, and the return value of a return > statement in a try block is copied from the variable before the finally > block is executed, so 1 will be returned. However, C# seems the odd one o= ut > (http://www.gettingclever.com/2008/07/return-from-finally.html). Hi: overwrite or not is easy to change, I impelent this according to java's behavior. but if we all think not overwrite is better, it's easy to change thanks --=20 =E6=83=A0=E6=96=B0=E5=AE=B8 laruence Senior PHP Engineer http://www.laruence.com