Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61464 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36495 invoked from network); 19 Jul 2012 09:49:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2012 09:49:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=dragoonis@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dragoonis@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.170 as permitted sender) X-PHP-List-Original-Sender: dragoonis@gmail.com X-Host-Fingerprint: 209.85.160.170 mail-gh0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:40843] helo=mail-gh0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3B/C1-25752-D18D7005 for ; Thu, 19 Jul 2012 05:49:17 -0400 Received: by ghbg2 with SMTP id g2so2914794ghb.29 for ; Thu, 19 Jul 2012 02:49:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=fxmjvYaAvzIVSTx9aMWrG7wNdeoRSB70KKLgAyL/tuY=; b=lNenpo5nZfLaM/Qq1zQ5dqR//3qVdYedr61XkenU/KMTZaSUXB7snAqxP7HXhwUzI2 ttlWT3Plf5zbmdFOh3gwSgel1hn9DeooxOsS+P4eN5rH5X7fUxak7AI4RqJ9g83jem5l BMQficFTcNKopEwJX+5KTB5nT6lUnh/7+eFmcGInGsKIP/ko+XWT41XkMYFcxrzBd05p mcWYDC6c/g9cCRJMCP8VObgzmN1wPNB2eIU/SJzo6xV3uEQAmUFTbCjXw8yWFJ67QS4U gfQZT5bo70hgZDn1MuRdh5kOq/kxh9pSF142OdqwiDC/7ORQoVGPIyF9zL8vuVJr9/31 +uiw== MIME-Version: 1.0 Received: by 10.50.94.196 with SMTP id de4mr763458igb.17.1342691353967; Thu, 19 Jul 2012 02:49:13 -0700 (PDT) Received: by 10.64.32.72 with HTTP; Thu, 19 Jul 2012 02:49:13 -0700 (PDT) In-Reply-To: <5007D707.2070100@hoa-project.net> References: <5007D707.2070100@hoa-project.net> Date: Thu, 19 Jul 2012 10:49:13 +0100 Message-ID: To: ivan.enderlin@hoa-project.net Cc: internals@lists.php.net Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Make try/catch brackets optinal From: dragoonis@gmail.com (Paul Dragoonis) Why is your try block only going to contain 1 line, and that's throwing an exception?? try throw new Exception('foobar'); catch(Exception $e) Braces are a good thing, they give structure and stop people from mis-reading things and writing bugs, the same can be said for the if() situation. 1) Braces are good. 2) Try with only one line in it to throw an exception doesn't seem like a realistic situation. -1 from me, sorry Hoa. On Thu, Jul 19, 2012 at 10:44 AM, Ivan Enderlin @ Hoa wrote: > Hi internals, > > As you certainly know, brackets defining blocks in PHP are optional if > blocks contain a single instruction. Thus: > > if($condition) { > echo 'foobar'; > } > > is strictly equivalent to: > > if($condition) > echo 'foobar'; > > But this syntactic sugar is not applied uniformly to all PHP language > constructions. I have the try/catch couple in mind. > First, I would like to know why it is not possible to write: > > try > throw new Exception('foobar'); > catch(Exception $e) > var_dump($e->getMessage()); > > as a strict equivalence of: > > try { > throw new Exception('foobar'); > } > catch(Exception $e) { > var_dump($e->getMessage()); > } > > Second, if it is possible, could we plan to have this =93feature=94 (unif= ormity > actually) in PHP6 (or maybe before)? > > Best regards. > > -- > Ivan Enderlin > Developer of Hoa > http://hoa.42/ or http://hoa-project.net/ > > PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis) > http://disc.univ-fcomte.fr/ and http://www.inria.fr/ > > Member of HTML and WebApps Working Group of W3C > http://w3.org/ > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >