Re: Make try/catch brackets optinal

From: Date: Thu, 19 Jul 2012 10:45:53 +0000
Subject: Re: Make try/catch brackets optinal
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-61474@lists.php.net to get a copy of this message
+1 for the consistency of it. It's surprising that: if ($foo) return $bar; else return 42; works and: try maybe_dangerous(); catch(Dynamite $e) handle_error(); does not. On Thu, Jul 19, 2012 at 12:11 PM, Peter Beverloo <peter@lvp-media.com> wrote: > On Thu, Jul 19, 2012 at 11:06 AM, Rafael Dohms <listas@rafaeldohms.com.br>wrote: > >> On Thu, Jul 19, 2012 at 12:03 PM, Charlie Somerville < >> charlie@charliesomerville.com> wrote: >> >> > This has code readability problem written all over it. When maintaining >> it >> > also has problems, like with the bracket-less if's. >> > You would need to add brackets if you add an extra line here, as well as >> > you might get unexpected behaviour of you forget to >> > add brackets in that case. >> > >> > I've often heard people make this argument, but I've never found it to be >> > a real concern in practise. >> > >> > Is this really such a common problem? >> > >> >> I have seen this problem happen, people losing time trying to figure out >> what is wrong only to find >> its a missing bracket. >> As Paul said, this is bug-prone. >> > > Other bracket-less blocks allow authors to shoot themselves in the foot > equally so, yet PHP supports these as well. The actual problem here is an > inconsistency in the parser, which I'd consider to be a bug. > > Peter > > >> -- >> Rafael Dohms >> PHP Evangelist and Community Leader >> http://www.rafaeldohms.com.br >> http://www.phpsp.org.br >>

« previous php.internals (#61474) next »