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, 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.

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.

Luckily, we can do something about it, and it happens to be easy.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to