On Wed, Jul 25, 2012 at 3:23 AM, Galen Wright-Watson <ww.ga...@gmail.com> wrote: > > > On Tue, Jul 24, 2012 at 5:03 AM, Xinchen Hui <larue...@gmail.com> wrote: >> >> Sent from my iPhone >> >> 在 2012-7-24,19:51,Rafael Kassner <kass...@gmail.com> 写道: >>> >>> >>> 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 = 1; > try { > return $r; > } catch (Exception $e) { > } finally { > $r = 2; > } > >>> >>> What will be returned? There is no possibility to return something in >>> finally, or finally will overwrite the return? >> >> >> overweite,although I think it make no sense return in finally block >> >> 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 out > (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 -- 惠新宸 laruence Senior PHP Engineer http://www.laruence.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php