On Wed, Jun 26, 2013 at 7:54 AM, Joost Koehoorn <joost.koeho...@gmail.com>wrote:
> On 26 juni 2013 at 08:35:59, Michael Wallner (m...@php.net) wrote: > On 25 June 2013 22:23, Johannes Schlüter <johan...@schlueters.de> 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 author > 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. Surely > 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 unused > 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. </my two cents>