Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61467 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40694 invoked from network); 19 Jul 2012 10:01:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2012 10:01:48 -0000 Authentication-Results: pb1.pair.com header.from=listas@rafaeldohms.com.br; sender-id=fail Authentication-Results: pb1.pair.com smtp.mail=listas@rafaeldohms.com.br; spf=fail; sender-id=fail Received-SPF: fail (pb1.pair.com: domain rafaeldohms.com.br does not designate 209.85.212.42 as permitted sender) X-PHP-List-Original-Sender: listas@rafaeldohms.com.br X-Host-Fingerprint: 209.85.212.42 mail-vb0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:44649] helo=mail-vb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CA/B2-25752-B0BD7005 for ; Thu, 19 Jul 2012 06:01:48 -0400 Received: by vbbfs19 with SMTP id fs19so2124011vbb.29 for ; Thu, 19 Jul 2012 03:01:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-gm-message-state; bh=zw5dh+kfgteXeDgYY8EN8aA6/TtQDoRJ1mpN3OlDsz4=; b=DF9t+6QhvZDvExB9b+TDqm0NgeGc6N1qnKPAOqdk3/lZdQkLnkTwKa8mgyO63ttVfJ lptlfy/LpJfL+xdEf08eC/LxUS3qW941pksH6X2mIKpypyQ9KTuM4d3dZSwneIqaq4az A95D6y1Zjpn41OxK2gjiW/58KsxYDPT5H1BOoB9visRdYA85eI+mMO1/txI+Oqtce7LC jvSQvAwkigT0dnqavv0mXjwcsR5JChkUzQVnrLa6eYuQK8IQaIYmfFRocXspjQ4eT6mr MKKen0o0qg5j0tqCE04wemw8+0I4mS5g/Wr/TGMQfMh7FrT4H6Ow4Bn0DgUAP+sotwps uaQw== MIME-Version: 1.0 Received: by 10.220.219.71 with SMTP id ht7mr639250vcb.3.1342692104787; Thu, 19 Jul 2012 03:01:44 -0700 (PDT) Received: by 10.220.46.13 with HTTP; Thu, 19 Jul 2012 03:01:44 -0700 (PDT) In-Reply-To: <5007D707.2070100@hoa-project.net> References: <5007D707.2070100@hoa-project.net> Date: Thu, 19 Jul 2012 12:01:44 +0200 Message-ID: To: ivan.enderlin@hoa-project.net Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=14dae9cfcdd0f2d71b04c52bddaa X-Gm-Message-State: ALoCoQkjKTDi5uNtCE//P+OoKZyRUt77RPpUGVH2RZgm6euQvB8oAKl7Fr9ShzC1J5tTc/H1s5Hw Subject: Re: [PHP-DEV] Make try/catch brackets optinal From: listas@rafaeldohms.com.br (Rafael Dohms) --14dae9cfcdd0f2d71b04c52bddaa Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On Thu, Jul 19, 2012 at 11:44 AM, Ivan Enderlin @ Hoa < ivan.enderlin@hoa-project.net> 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. > Writing if blocks without brakets is considered a bad practice. IMHO anyway= . > 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()); > > 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. > 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 > (uniformity actually) in PHP6 (or maybe before)? > > Sorry, -1 from me. --14dae9cfcdd0f2d71b04c52bddaa--