Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61490 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85299 invoked from network); 19 Jul 2012 15:43:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2012 15:43:56 -0000 Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 66.111.4.27 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 66.111.4.27 out3-smtp.messagingengine.com Received: from [66.111.4.27] ([66.111.4.27:39301] helo=out3-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 88/00-18983-B3B28005 for ; Thu, 19 Jul 2012 11:43:56 -0400 Received: from compute4.internal (compute4.nyi.mail.srv.osa [10.202.2.44]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 433DD20527 for ; Thu, 19 Jul 2012 11:43:53 -0400 (EDT) Received: from frontend2.nyi.mail.srv.osa ([10.202.2.161]) by compute4.internal (MEProxy); Thu, 19 Jul 2012 11:43:53 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:date:from:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; s=smtpout; bh=vGJ0p7NdNWPvqKs5/L4zAA UzVk4=; b=qpuFDg6o7raMRnS8YE/wxNjvtoazsSvcCRmfPF4gDXQsQ4VttlDG4U lktSdgqudhi1gTUKfWUSbamcSMP/burgeOpRnqaRngguO2VbmivM714fkGN07dqk WhVtNDXW8frwSZIlMGhgTMJz+5BMmPQ4AuXtBH2prAqJSiWd83nA8= X-Sasl-enc: s4l5DVK8EQ2gM7CDKEfbjwUFmuiaxWRKcfkUuKUj7Tbr 1342712633 Received: from Palantirs-MacBook-Pro.local (unknown [209.41.114.202]) by mail.messagingengine.com (Postfix) with ESMTPA id 0D05748264D for ; Thu, 19 Jul 2012 11:43:53 -0400 (EDT) Message-ID: <50082B38.1070603@garfieldtech.com> Date: Thu, 19 Jul 2012 10:43:52 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: internals@lists.php.net References: <5007D707.2070100@hoa-project.net> <095CAA408DA94AFB9E75C12877A9043D@charliesomerville.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Make try/catch brackets optinal From: larry@garfieldtech.com (Larry Garfield) On 7/19/12 5:11 AM, Peter Beverloo wrote: >> 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 PHP doesn't support optional brackets on functions, either; please no one suggest that. Yes, it's inconsistent that some structures allow short-circuited brackets. The solution isn't to let all structures have the bug-attracting syntax. If it wouldn't break a few zillion lines of existing code I'd say we should resolve the inconsistency by making the braces required on if/foreach/etc. PHP only has them optional due to a C/C++ legacy, which may have made sense when the byte size of source code actually mattered for storage efficiency. Yes, I have run into bugs that were caused by people forgetting braces. Yes, I have introduced bugs without realizing it because someone left off a brace and I didn't notice it. Yes, I now always add braces when looking at someone's code; I can't even read it otherwise anymore. Any respectable coding standard requires the otherwise-optional braces. And yes, I always close my

tags as well, and so should you! :-) --Larry Garfield