Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67862 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11587 invoked from network); 26 Jun 2013 12:29:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jun 2013 12:29:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=theanomaly.is@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=theanomaly.is@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.49 as permitted sender) X-PHP-List-Original-Sender: theanomaly.is@gmail.com X-Host-Fingerprint: 74.125.82.49 mail-wg0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:47298] helo=mail-wg0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 16/65-18025-EAEDAC15 for ; Wed, 26 Jun 2013 08:29:35 -0400 Received: by mail-wg0-f49.google.com with SMTP id a12so10180125wgh.28 for ; Wed, 26 Jun 2013 05:29:32 -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; bh=cgyAYcDiiKtzss3HW7HhI5Ci0709mtqeRUinCXVU7z4=; b=VXRGyTAKHGMJTKQSi9DGo0zqbiGKYWiEzKvuV9fxQF1eol5UTO6mf8e3/Xv5XtVRUt 2BHQei6kMdSo+gNnjSROD+nCPzdNej3ciQ0Ig8fJ6lzRwTY5jxS0b+snPwwl0yCKUoBs 0UF4xWZucCK7GxuXM8hVekd5CYHA/wxp9a5nRddPIOEQbP/HkPPRU4rWwWDfchbHfl1g 7ClFh/qPZVE+cDUKYqIxowGj+up51DkAJonnwOAZHcaOx63Oh3oidtr241uPSGkmDrD4 TmDoL0pq3ow/hbWXypdl7eEgNaIktROY7+juA596NinV4n84l+QfnKW6MobrsGBZzdmk 1Rtw== MIME-Version: 1.0 X-Received: by 10.194.133.106 with SMTP id pb10mr2567095wjb.62.1372249772043; Wed, 26 Jun 2013 05:29:32 -0700 (PDT) Received: by 10.227.60.205 with HTTP; Wed, 26 Jun 2013 05:29:31 -0700 (PDT) In-Reply-To: References: <4ED7146272E04A47B986ED49E771E347BB4DF6F235@Ikarus.ameusgmbh.intern> <51C9DED2.5080401@sugarcrm.com> <51C9F485.6050709@sugarcrm.com> <51C9FB61.3050903@sugarcrm.com> <1372191793.2389.80.camel@guybrush> Date: Wed, 26 Jun 2013 08:29:31 -0400 Message-ID: To: Joost Koehoorn Cc: Michael Wallner , =?ISO-8859-1?Q?Johannes_Schl=FCter?= , Stas Malyshev , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e0115f11234b6c704e00dcc7b Subject: Re: [PHP-DEV] RE: Announcing RFC 'Anonymous Catches' From: theanomaly.is@gmail.com (Sherif Ramadan) --089e0115f11234b6c704e00dcc7b Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Wed, Jun 26, 2013 at 7:54 AM, Joost Koehoorn w= rote: > On 26 juni 2013 at 08:35:59, Michael Wallner (mike@php.net) wrote: > On 25 June 2013 22:23, Johannes Schl=FCter wrote= : > > On Tue, 2013-06-25 at 13:19 -0700, Stas Malyshev wrote: > >> Hi! > >> > >> > If I'm to understand this RFC correctly, it is nothing more than a > >> > random suggestion someone posed in the form of a tweet and the autho= r > is > >> > saying why not add it since it's not hard to implement. So in > summation > >> > >> Well, here we go - this is why not add it, because it makes working > with > >> such code harder without actually benefiting anybody. > > > > +1 > > > > Right now I set a breakpoint in my editor and look at an exception even > > if it is not used, in future I'd have to change the code for that. > > Hrm, this is a very good point! > > >> > So this entire discussion can be summed up nicely with "Let's make > the > >> > variable optional because... why not?". > >> > >> "Why not" is usually not a very good principle of language design, IMO= . > > > Nothing more to add. > > -- > Regards, > Mike > This is a little pathetic. Someone sums it up to "Why not", which is not > the case, we have grounded arguments for this, Not really. The arguments posed so far are "I want to get rid of the variable because I'm not using the variable", which isn't a justification. It's just a circular argument that can go both ways. You can get what you want and still not get rid of the variable. The difference is if you get rid of it you make code harder to debug and thus promote worse practices than already exist in PHP. > and then all agree that "Why not" is not a reason to add something. Surel= y > it isn't. > > You mention bad coding practices. Sure, we should avoid them. Unused > variables is a bad coding practice. So, we should avoid them. Luckily, it= 's > easy to avoid them with catch-statements, because we can simply make the > variable optional. > You can avoid bad practices by allowing the practice to exist where it does not already? Surely this doesn't make sense when you re-read it out loud. > > I recently wrote a CLI tool in C# to import data from Team Foundation > Server. During an update, I try to download every new commits from where = I > last stopped (so, from commit "latest+1"). That fails with a > ChangesetNotFoundException when no such commit exists, fair enough. I > cannot test beforehand whether that exception will be thrown (that would > mean I needed two calls to the server, now it's in one round) so it's > totally expected. I'm doing this for 100.000 files and I don't want to do > anything with the exception, it's nothing more than an indication that > we're already up-to-date for that file. Done. In PHP I would have an unus= ed > variable, which trips up my static analysis tool that keeps warning me > about the bad coding practice of having an unused variable. I agree, it's > bad to have that variable defined but PHP won't let me get rid of it. > Another reason for people to bitch about PHP. > So basically the only argument you have here is that you want to change PHP to get your IDE to stop complaining about unused variables? I'm not even going to justify the "Another reason for people to bitch about PHP" since that conversation really doesn't even belong in Internals discussion. > > Luckily, we can do something about it, and it happens to be easy. > We can also just as easily ignore the variable in user space. Doing so will at least leave the user with a means to consider why they're catching Exceptions that might not be handling well. I understand you feel you have no reason to touch the exception variable, but this is not a good enough reason to get rid of it. Anytime you get rid of information that's available to user space that can be used to debug code you are losing something valuable. It may not be valuable to you, but this is the exception and not the rule. We should not be throwing this information away. --089e0115f11234b6c704e00dcc7b--