Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61475 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54232 invoked from network); 19 Jul 2012 10:54:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2012 10:54:27 -0000 Authentication-Results: pb1.pair.com header.from=reeze.xia@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=reeze.xia@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.42 as permitted sender) X-PHP-List-Original-Sender: reeze.xia@gmail.com X-Host-Fingerprint: 209.85.160.42 mail-pb0-f42.google.com Received: from [209.85.160.42] ([209.85.160.42:56631] helo=mail-pb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A1/75-25752-167E7005 for ; Thu, 19 Jul 2012 06:54:26 -0400 Received: by pbbrp12 with SMTP id rp12so4533211pbb.29 for ; Thu, 19 Jul 2012 03:54:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:message-id:in-reply-to:references:subject:x-mailer :mime-version:content-type; bh=kGBdBCxXTjWRgycH2Wdyg1Acn6M1rfsoaf+oRlnVNSg=; b=KbN6qANDbfpS3YKn/K9CiQCWGR+aUpHW1zMgj/28ue86OkWnUV1gW6qa1tg19xezLE 55wcwatHHW1ISO40QyfTR6s70MAQTDEjSdRQjvSlseh3+uR+vmATDWNkKMvjXqTsfqVc Nxh82loYyu0EfRY0jKEkVFbw6QHk+DX1Fug30UxwwIOrleGCMyQtU4A7vVFqbxetSqoI U5/F9LhPWsfoNT7hgLu9GvB0P1UyVeNHDA3cYcHlDGjIfHzxjOYe72ZBDO5v/sv+v7kT tmHw08U2Uiqv7W5IQMUJQ0LqaHAbxvAlE8SzxT5oJhG+XALtnMlEMxdZaWRjxgJDA0bv jKMw== Received: by 10.68.227.195 with SMTP id sc3mr4326226pbc.104.1342695262786; Thu, 19 Jul 2012 03:54:22 -0700 (PDT) Received: from [172.22.234.236] ([61.135.169.76]) by mx.google.com with ESMTPS id se9sm1580832pbc.25.2012.07.19.03.54.17 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 19 Jul 2012 03:54:21 -0700 (PDT) Date: Thu, 19 Jul 2012 18:54:56 +0800 To: Rune Kaagaard Cc: Peter Beverloo , Rafael Dohms , Charlie Somerville , ivan.enderlin@hoa-project.net, internals@lists.php.net Message-ID: <36467402DA0F4332A523162E3C278042@gmail.com> In-Reply-To: References: <5007D707.2070100@hoa-project.net> <095CAA408DA94AFB9E75C12877A9043D@charliesomerville.com> X-Mailer: sparrow 1.6.3beta (build 1165) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="5007e780_77ae35eb_1060e" Subject: =?utf-8?Q?=E5=9B=9E=E5=A4=8D=EF=BC=9A_?=[PHP-DEV] Make try/catch brackets optinal From: reeze.xia@gmail.com (Reeze) --5007e780_77ae35eb_1060e Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi=EF=BC=8C =E5=9C=A8 2012=E5=B9=B47=E6=9C=8819=E6=97=A5=E6=98=9F=E6=9C=9F=E5=9B=9B=EF= =BC=8C=E4=B8=8B=E5=8D=886:45=EF=BC=8CRune Kaagaard =E5=86=99=E9=81=93=EF=BC= =9A > +1 for the consistency of it. It's surprising that: > =20 > if (=24foo) > return =24bar; > else > return 42; > =20 > works and: > =20 > try > maybe=5Fdangerous(); > catch(Dynamite =24e) > handle=5Ferror(); > =20 > =20 There is no condition after =60try=60, it's really hard to read without b= racket. =20 it becomes even worse if it didn't format pretty as above. > does not. > =20 > On Thu, Jul 19, 2012 at 12:11 PM, Peter Beverloo wrote: > > On Thu, Jul 19, 2012 at 11:06 AM, Rafael Dohms wrote: > > =20 > > > On Thu, Jul 19, 2012 at 12:03 PM, Charlie Somerville < > > > charlie=40charliesomerville.com (mailto:charlie=40charliesomerville= .com)> wrote: > > > =20 > > > > This has code readability problem written all over it. When maint= aining > > > 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. > > > > =20 > > > > I've often heard people make this argument, but I've never found = it to be > > > > a real concern in practise. > > > > =20 > > > > Is this really such a common problem=3F > > > =20 > > > I have seen this problem happen, people losing time trying to figur= e out > > > what is wrong only to find > > > its a missing bracket. > > > As Paul said, this is bug-prone. > > > =20 > > =20 > > =20 > > Other bracket-less blocks allow authors to shoot themselves in the fo= ot > > equally so, yet PHP supports these as well. The actual problem here i= s an > > inconsistency in the parser, which I'd consider to be a bug. > > =20 > > Peter > > =20 > > =20 > > > -- > > > Rafael Dohms > > > PHP Evangelist and Community Leader > > > http://www.rafaeldohms.com.br > > > http://www.phpsp.org.br > > > =20 > > =20 > > =20 > =20 > =20 > -- =20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > =20 > =20 --5007e780_77ae35eb_1060e--