Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61470 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43440 invoked from network); 19 Jul 2012 10:04:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2012 10:04:06 -0000 Authentication-Results: pb1.pair.com header.from=charlie@charliesomerville.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=charlie@charliesomerville.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain charliesomerville.com from 209.85.161.170 cause and error) X-PHP-List-Original-Sender: charlie@charliesomerville.com X-Host-Fingerprint: 209.85.161.170 mail-gg0-f170.google.com Received: from [209.85.161.170] ([209.85.161.170:58204] helo=mail-gg0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 79/53-25752-39BD7005 for ; Thu, 19 Jul 2012 06:04:05 -0400 Received: by ggnf2 with SMTP id f2so2927473ggn.29 for ; Thu, 19 Jul 2012 03:04:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:message-id:in-reply-to:references:subject:x-mailer :mime-version:content-type:x-gm-message-state; bh=xxgjajbhYOnY326uj5opCrj7rr73qyxIZjDTEb+vJJ8=; b=AV861c/vOIWu0YcOfGprIVTvlIWMYY/2RvtSVO9x+wQCnVTOG5qBIIhLGpg6P1L1UW CElVBAJCUntnkke/7OyC25vFu1iTz9DU2xhNJBXYSWEH+r4mAK3YjgU1+Cvd+XBkoLUK 0GD+VVi8SFk69wB+048JoKi1jYoU3jGhoDlvdtfpWS/W/Uf3PCNINhJY2KGW0FZL3GOR h9+eqkYyDQ3en2Jbp/uDwavyvdwFLCM1TfmAZMoJY5jctkRY2Do5fHxUNlU3xvuEallB 1iFb6Df2RyIwYdXqYYd7AVTRBfsIQGyqgmxWR0dnO2aiDwY10k+zCeZOrfpXC0H4X3Oo rGvA== Received: by 10.68.224.36 with SMTP id qz4mr3855713pbc.161.1342692240688; Thu, 19 Jul 2012 03:04:00 -0700 (PDT) Received: from charlies-macbook-pro.fritz.box (124-149-151-83.dyn.iinet.net.au. [124.149.151.83]) by mx.google.com with ESMTPS id op10sm1493369pbc.75.2012.07.19.03.03.57 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 19 Jul 2012 03:03:59 -0700 (PDT) Date: Thu, 19 Jul 2012 20:03:51 +1000 To: Rafael Dohms Cc: ivan.enderlin@hoa-project.net, internals@lists.php.net Message-ID: <095CAA408DA94AFB9E75C12877A9043D@charliesomerville.com> In-Reply-To: References: <5007D707.2070100@hoa-project.net> X-Mailer: sparrow 1.5 (build 1043.1) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="5007db88_4b588f54_8327" X-Gm-Message-State: ALoCoQlHrg5n5g51RYTsJPUvJLUe1SELHgP7rvPt6TC4u+UXnRZgH2V6zPzakoSf8NLus/6FQ8J9 Subject: Re: [PHP-DEV] Make try/catch brackets optinal From: charlie@charliesomerville.com (Charlie Somerville) --5007db88_4b588f54_8327 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline > 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 a= s > you might get unexpected behaviour of you forget to > add brackets in that case. > =20 > =20 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=3F =20 On Thursday, 19 July 2012 at 8:01 PM, Rafael Dohms wrote: > On Thu, Jul 19, 2012 at 11:44 AM, Ivan Enderlin =40 Hoa < > ivan.enderlin=40hoa-project.net (mailto:ivan.enderlin=40hoa-project.net= )> wrote: > =20 > > Hi internals, > > =20 > > As you certainly know, brackets defining blocks in PHP are optional i= f > > blocks contain a single instruction. Thus: > > =20 > > if(=24condition) =7B > > echo 'foobar'; > > =7D > > =20 > > is strictly equivalent to: > > =20 > > if(=24condition) > > echo 'foobar'; > > =20 > > But this syntactic sugar is not applied uniformly to all PHP language= > > constructions. I have the try/catch couple in mind. > > =20 > =20 > =20 > Writing if blocks without brakets is considered a bad practice. IMHO an= yway. > =20 > =20 > > =46irst, I would like to know why it is not possible to write: > > =20 > > try > > throw new Exception('foobar'); > > catch(Exception =24e) > > var=5Fdump(=24e->getMessage()); > > =20 > =20 > 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 a= s > you might get unexpected behaviour of you forget to > add brackets in that case. > =20 > =20 > > as a strict equivalence of: > > =20 > > try =7B > > throw new Exception('foobar'); > > =7D > > catch(Exception =24e) =7B > > var=5Fdump(=24e->getMessage()); > > =7D > > =20 > > Second, if it is possible, could we plan to have this =E2=80=9Cfeatur= e=E2=80=9D > > (uniformity actually) in PHP6 (or maybe before)=3F > > =20 > =20 > Sorry, -1 from me. > =20 > =20 --5007db88_4b588f54_8327--