Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67802 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95473 invoked from network); 25 Jun 2013 11:18:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jun 2013 11:18:54 -0000 Authentication-Results: pb1.pair.com header.from=joost.koehoorn@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=joost.koehoorn@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.47 as permitted sender) X-PHP-List-Original-Sender: joost.koehoorn@gmail.com X-Host-Fingerprint: 74.125.82.47 mail-wg0-f47.google.com Received: from [74.125.82.47] ([74.125.82.47:47922] helo=mail-wg0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 60/59-49518-C9C79C15 for ; Tue, 25 Jun 2013 07:18:53 -0400 Received: by mail-wg0-f47.google.com with SMTP id l18so9080503wgh.2 for ; Tue, 25 Jun 2013 04:18:50 -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:content-transfer-encoding; bh=BSA5P4i+Strk7KqlMQXL9OB3sxSJcMkG8pz1WcG0DcA=; b=LvZeD0xrVErgWJTc5cSvf/fAouAUOROm7+f5Wdv4cbcOAyuuiR+4Fycs9+gXSmbQTq SntsNPlm6kKk+IZ+zKEhvXFuokP6HJODljZIhn/PFB3nucPuDCqLcq9KCrWvQXamFBSI wwLYdFk1SoXjknVfsuG/8HippyGUBfwh9voCsEQr1yDuVSjiGNWmTyDad2GF/b6njKJJ AQUAnYYfo1z3RVWcg/FhEU0DFw4MFT7g+oEt6HVedXe0SSvboWB+COLsjMCHRrEr4A1i DKP5YKOwLloBimehRIcY7baJj9mL+lm7Tx+EE6CQtK8k10wBi5YU0ia/tyijkkIBmK6x qvwg== X-Received: by 10.180.74.146 with SMTP id t18mr8920252wiv.3.1372159130233; Tue, 25 Jun 2013 04:18:50 -0700 (PDT) Received: from MacBook-Air-van-Joost-Koehoorn.local (178-85-180-81.dynamic.upc.nl. [178.85.180.81]) by mx.google.com with ESMTPSA id cd11sm3386565wib.10.2013.06.25.04.18.48 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 25 Jun 2013 04:18:49 -0700 (PDT) Date: Tue, 25 Jun 2013 13:18:50 +0200 To: Christian Stoller Cc: Message-ID: In-Reply-To: <4ED7146272E04A47B986ED49E771E347BB4DF6F235@Ikarus.ameusgmbh.intern> References: <4ED7146272E04A47B986ED49E771E347BB4DF6F235@Ikarus.ameusgmbh.intern> X-Mailer: Airmail Beta (183) MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: =?UTF-8?Q?RE=3A_Announcing_RFC_'Anonymous_Catches'?= From: joost.koehoorn@gmail.com (Joost Koehoorn) > Hi all,=C2=A0 >=C2=A0 > I just published an R=46C that proposes to add catch-statement without = needing to specify a variable, and support for fully > anonymous catches.= =C2=A0 >=C2=A0 > Details can be found at:=C2=A0 >=C2=A0 > https://wiki.php.net/rfc/anonymous=5Fcatch=C2=A0 >=C2=A0 > Regards,=C2=A0 >=C2=A0 > Joost Koehoorn=C2=A0 >=C2=A0 Hi.=C2=A0 I am not sure about complete anonymous catch statement (like try =7B =7D = catch =7B =7D), but I really like the proposal for omitting the exception= variable.=C2=A0 Because in frameworks like Symfony there are defined and used a lot of sp= ecial exception types for each cases.=C2=A0 Here's an example that shows what I mean:=C2=A0 try =7B=C2=A0 =24foo->authenticate(=24user);=C2=A0 =7D catch (BadCredentialsException) =7B=C2=A0 echo =22Bad credentials=22;=C2=A0 =7D catch (InactiveAccount) =7B=C2=A0 echo =22Sorry, your account is not active anymore.=22;=C2=A0 =7D catch (CurlErrorOnAuthService) =7B=C2=A0 echo =22Please try again later, the login service is currently unavailabl= e.=22;=C2=A0 =7D catch (Exception) =7B=C2=A0 echo =22bla blubb=22;=C2=A0 =7D=C2=A0 In such a case you do not need any =60=24e=60variable. Netbeans for examp= le always highlight's these variables because it is not used anywhere. Bu= t I think it looks a bit cleaner if the variable could be omitted, if it'= s not needed ;-)=C2=A0 Best regards=C2=A0 Christian This is exactly the reason, yes=21 As stated in the R=46C, I think it's best that we consider the two ways s= eparately. Omitting the variable is a much smaller change (and requires v= ery little code changes) than having a fully anonymous catch. I originally dived into this because of a question of Phil Sturgeon on tw= itter, requesting for making the variable optional. I took it one step fu= rther and made the whole thing optional, but surely we can decide to only= make the variable optional, I can see how it's bad programming practice = to have fully anonymous blocks (even though sometimes they may be used). = Just throwing this out here to see what you think about it. Regards, Joost