Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67806 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28179 invoked from network); 25 Jun 2013 13:15:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jun 2013 13:15:37 -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 209.85.212.178 as permitted sender) X-PHP-List-Original-Sender: joost.koehoorn@gmail.com X-Host-Fingerprint: 209.85.212.178 mail-wi0-f178.google.com Received: from [209.85.212.178] ([209.85.212.178:63750] helo=mail-wi0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C9/40-49518-8F799C15 for ; Tue, 25 Jun 2013 09:15:37 -0400 Received: by mail-wi0-f178.google.com with SMTP id k10so734759wiv.11 for ; Tue, 25 Jun 2013 06:15:34 -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=+A7WqFhosOG70JBzCmDilM54QA+8P+mDx44WwEEy6cI=; b=ssmW2tIXC9cVXUojcSW616p9oiMb77Ulw96ObN2fRa/4MaCRhw1m6iRwIg5afTyAMn uhpJqCQePjdersq1qG6WuH07IJxE0CGOlRyG/1bYNjF02qUqTXVTYJ6SS8GxpGaYsFmJ w6+34nlTtvZB4Tp5WHiTT1KHyGVvk5di4Tm87SwSNK0JeEnougBefe3qx16FIELj3AEe 6oxqPTmTpg1WBgyJ0Y6WtfmXF1PHsz+XZU/WBZLzkYasME1q+yqMQ+Ts77Y7ghHzQLGO tFc1ywPNfilpJP1fmPUPAMfvLigDqfWISkny4KN4CAjjaACsdQdUm7rtPDGUvqxqPauO 8abw== X-Received: by 10.180.106.72 with SMTP id gs8mr9196789wib.51.1372166134054; Tue, 25 Jun 2013 06:15:34 -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 p1sm4041042wix.9.2013.06.25.06.15.31 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 25 Jun 2013 06:15:32 -0700 (PDT) Date: Tue, 25 Jun 2013 15:15:30 +0200 To: Florin Patan Cc: Message-ID: In-Reply-To: References: 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) On Tue, Jun 25, 2013 at 12:54 AM, Joost Koehoorn=C2=A0 wrote:=C2=A0 > 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 > --=C2=A0 > PHP Internals - PHP Runtime Development Mailing List=C2=A0 > To unsubscribe, visit: http://www.php.net/unsub.php=C2=A0 >=C2=A0 Hi,=C2=A0 =46irst of, considering that you would only save three characters by=C2=A0= having the ' =24e' removed, I don't see how it would make things easier=C2= =A0 to learn. I mean if you can't learn that maybe you should look into=C2=A0= something else that's not related to programming :) I don't recall mentioning that this makes PHP easier to learn. It's reall= y about avoiding introducing unused variables, which is currently require= d because the language simply requires and identifier there. Having this: =22* Avoid indication of a specific exception type=22 could=C2= =A0 be considered as a possible bad practice, just as you were saying that=C2= =A0 catch(=5CException =24e) is. Also, it you can add the other ten character= s=C2=A0 that you save when typing =5CException but does it worth it=3F I don't really care about saving a few characters, that's not what this i= s about. I can see that a catch-all can be considered bad practice, but p= erform a Github search for =60catch (Exception =24e)=60 and find very muc= h instances of this usage. In all of these situations it seems that only = specific exceptions are caught, but that's not actually the case. We curr= ently see that requiring an Exception type doesn't really enforce good pr= ogramming practice, most instances simply use =60(=5CException =24e)=60 a= nd have the same bad practice. How do you plan to handle this: * Note that there may only be one=C2=A0 anonymous catch-statement, and it has to be the last one. Throw a=C2=A0 fatal error=3F If not then what, nothing=3F In my current implementation, it's simply a syntax error and thus will ne= ver result in compiled code. What are the performance downsides of having this check in place=3F I do=C2= =A0 understand that you mentioned: =22* Runtime needs to perform less=C2=A0 checks. No need to update the symboltable, no need to check exception=C2=A0= inheritance. =22 but wouldn't that be replaced by what I'm asking about=3F= =C2=A0 If I could read/understand C better I wouldn't ask for this. As it's directly enforced by the language grammer, Bison (the parser gene= rator) won't accept invalid use of the anonymous catch, and thus no addit= ional runtime checks are necessary. Could you also please elaborate this: =22* Better possibilities for=C2=A0= static analysis tools=22=3F=C2=A0 This is about unused variables. When you use an IDE or tools such as PHPM= D, they will warn you about unused variables in your code. Exception vari= ables are simply required by the language, even though you may not actual= ly use them, thus generating unused variables warnings (or the analyser d= oesn't flag exception variables, in which case you miss unused variables)= which you cannot solve.=C2=A0 As for: * People from other languages such as C=23, Python and Ruby=C2=A0= expect this to work I think it is often pointed out when requesting=C2=A0= features such as function/method return type hinting (I'm planning a=C2=A0= R=46C for that), named parameters, threads and other stuff that this=C2=A0= ain't C=23, Java, Python, Ruby or whatnot so.. what's the official=C2=A0 position on this=3F Do we want PHP like the other languages or not (and=C2= =A0 I won't say more on this here/now)=3F I can agree with you here, PHP has its own things and is different from o= ther languages for a reason. I'm mentioning this because I can see how Py= thon/Ruby developers working with PHP may find this a flaw in PHP, giving= them another reason to bitch about PHP. Also, the code sample is not that good. If you want to reflect a good=C2=A0= quality scenario, it should be more like:=C2=A0 while (true) =7B=C2=A0 try=C2=A0 =7B=C2=A0 =24this->connectToServer();=C2=A0 break;=C2=A0 =7D=C2=A0 catch (Connection=46ailedException)=C2=A0 =7B=C2=A0 sleep(3);=C2=A0 =7D=C2=A0 =7D=C2=A0 And I think the R=46C should also add a: Disadvantages section so that=C2= =A0 it could help people looking on it and proving that you've done all=C2=A0= the research correctly. I couldn't really come up with disadvantages. Anonymous catch-statements = may be considered bad coding practice, but look at the amount of develope= rs simply using =60Exception=60 as the type which is the same bad practic= e, only with the false indication that a specific type is expected. By al= lowing for not specifying the type at all, it's immediately clear that th= e intention was to not care about the type at all. Thanks=C2=A0 ----=C2=A0 =46lorin Patan=C2=A0 https://github.com/dlsniper=C2=A0 http://www.linkedin.com/in/florinpatan