Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61483 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70039 invoked from network); 19 Jul 2012 13:16:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2012 13:16:07 -0000 Authentication-Results: pb1.pair.com header.from=sebastian.krebs.berlin@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=krebs.seb@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: krebs.seb@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:53881] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C4/78-25752-49808005 for ; Thu, 19 Jul 2012 09:16:04 -0400 Received: by weyr1 with SMTP id r1so2006650wey.29 for ; Thu, 19 Jul 2012 06:16:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:x-google-sender-delegation:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type; bh=T1sfFBfxiDyJKPl1E661Rm4AmUt0qeSzcxFWJAARU1w=; b=U4pqcoxxnQKfCUEjYjSStG0+AD4C+lbABgOSb3ikBuy5xfQm+XYrG9SgqauPCoP4Wm +5vFSGEet5WHz3Z0IElPtTrfr54Vu1SdApVzlLbUKRRmweNot1poyZeELM/1ggyUWgQy j5a4pzEPavNphAHe6XVbO877U9F3fCtAd5e2qQVGR4oYogeLqhgY7ztYSjzLpnkHuyCS shnT/pw/M9xOGgAiLQunFtBYSbRWEIV84tZ3bundIsRuOR8wy156e0Jw9kwKP7LJwxTa n1Eds683LSGBAmHpD5Hj4e8rTL4/CLCsM0jVWMXixZEJR+zEQ/gg43Vr1oKKa7R/m32J Wp0w== MIME-Version: 1.0 Received: by 10.216.135.217 with SMTP id u67mr1279597wei.115.1342703761680; Thu, 19 Jul 2012 06:16:01 -0700 (PDT) Sender: sebastian.krebs.berlin@gmail.com X-Google-Sender-Delegation: sebastian.krebs.berlin@gmail.com Received: by 10.14.134.201 with HTTP; Thu, 19 Jul 2012 06:16:01 -0700 (PDT) In-Reply-To: References: <5007D707.2070100@hoa-project.net> <095CAA408DA94AFB9E75C12877A9043D@charliesomerville.com> Date: Thu, 19 Jul 2012 15:16:01 +0200 X-Google-Sender-Auth: rn3-Bm_hhL3XJ2qWNXdc6qB4cuE Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=0016e6de03b2c0e94f04c52e9423 Subject: Re: [PHP-DEV] Make try/catch brackets optinal From: krebs.seb@gmail.com (Sebastian Krebs) --0016e6de03b2c0e94f04c52e9423 Content-Type: text/plain; charset=ISO-8859-1 2012/7/19 Rafael Dohms > 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. > Just curious (once more): How can anyone overlook, that the brackets are intentionally omitted here? if ($x) { // Do something } else return null; Of course it's a matter of code style [1], but one can write the ugliest code with every syntax. This argument about "bug-prone" often confuses me, because I for myself never had such a problem. I also never knew someone, who had a problem with bracket-less blocks (but must say, that most write blocks _with_ brackets, thus they _may_ have problems). I've often just heard this "its bug-prone" (that sounds to me like "there are inattentive devs out there" to me :X) as as killer argument... At the end of the day I don't really care wether I should avoid bracket-less blocks, or not, but ... it's this argument that annoys me :X And I just think this just looks cute :) try $calculator->calculateSomeVeryDifficultStuff() catch ($e) { // on failure } 2cent and so on Regards, Sebastian [1] I would wrap "return null;" in brackets too, if the line gets too long. if ($x) { // Do something } else { return someVeryLongStatement() && andSuch(); } > -- > Rafael Dohms > PHP Evangelist and Community Leader > http://www.rafaeldohms.com.br > http://www.phpsp.org.br > --0016e6de03b2c0e94f04c52e9423--