July 30, 2012
On Monday, 30 July 2012 at 17:39:31 UTC, bearophile wrote:
> Namespace:
>
>>> I suggest to attach both code and testcases to:
>>> http://d.puremagic.com/issues/show_bug.cgi?id=3960
>>
>> Done.
>
> I see no attachments :-( Only ephemeral links.
>
> Bye,
> bearophile

Sorry, but i can upload only one file. I will upload my unused_vars.d immediately.

Jonathan M Davis:
Walter hates so much things, nearly all what the community wishes for: not null types, warnings for unused variables, warnings for unused imports and so on.
It does not only count what he wants but what is useful, IMO.
July 30, 2012
On Monday, July 30, 2012 20:39:02 Namespace wrote:
> Jonathan M Davis:
> Walter hates so much things, nearly all what the community wishes
> for: not null types, warnings for unused variables, warnings for
> unused imports and so on.
> It does not only count what he wants but what is useful, IMO.

Plenty of the community agrees with him too, much as there may be some vocal folks who don't. Regardless, because he's the gatekeeper of the reference compiler, he has to be convinced if you want a feature added to either the language or the compiler. He's generally quite reasonable, but he also has a high bar for feature changes.

- Jonathan M Davis
July 30, 2012
> Plenty of the community agrees with him too, much as there may be some vocal
> folks who don't. Regardless, because he's the gatekeeper of the reference
> compiler, he has to be convinced if you want a feature added to either the
> language or the compiler. He's generally quite reasonable, but he also
> has a high bar for feature changes.
>
> - Jonathan M Davis

That's right. But the majority of programming languages has this feature, but D does not. This feature is undeniable effective, so IMO there is no reason which stands against a warning for unused variables. Or can you tell me some personal reasons, without quoting Walter?
July 30, 2012
BTW: Has anyone test my detector and could give me some suggestions or critism?
July 30, 2012
On 31-Jul-12 00:02, Namespace wrote:
> BTW: Has anyone test my detector and could give me some suggestions or
> critism?

I haven't tested it but offhand I call it inaccurate :)
I had only cursory look at it but: regexes are way underpowered to do the task and thus false positives and false negatives are unavoidable.

Just throw in more templates and mixins and it will fail ;)
-- 
Dmitry Olshansky
July 30, 2012
On 07/30/2012 12:02 PM, Namespace wrote:

> there is no reason which stands against a warning for unused variables.
> Or can you tell me some personal reasons, without quoting Walter?

People comment-out parts of code during development and debugging, leaving unused variables behind (just for a while). Receiving compilation errors for those is not productive. (Warnings would be the same thing as they should be treated as errors.)

Additionally, some unused variables do very important work (e.g. RAII structs). Should the compiler warn for only the ones that do not have side-effects in their constructors and destructors?

Such questions are not easy to answer.

Ali

July 30, 2012
On Monday, July 30, 2012 21:02:14 Namespace wrote:
> That's right. But the majority of programming languages has this feature, but D does not. This feature is undeniable effective, so IMO there is no reason which stands against a warning for unused variables. Or can you tell me some personal reasons, without quoting Walter?

Aside from the fact that it can be really annoying when the compiler complains about unused parameters? I believe that the bug report that you posted to includes some discussion on some of the technical issues caused by making unused variables a warning. In particular, it causes problems for generic code as well as template constraints. A _lot_ of templates used for template constraints would generate warnings if usused variables were a warning. So, if you were compiling with -w, it would become _very_ easy to have your program not compile. And there are plenty of cases where generated code ends up with unused variables, and it's fine.

I grant you that it's undesirable to have unused variables sitting around in most functions, but there _are_ cases where disallowing that (as making it a warning effectively does) causes problems. This is the sort of thing that's better left to a lint-like tool IMHO.

- Jonathan M Davis
July 30, 2012
On Monday, 30 July 2012 at 20:06:42 UTC, Dmitry Olshansky wrote:
> On 31-Jul-12 00:02, Namespace wrote:
>> BTW: Has anyone test my detector and could give me some suggestions or
>> critism?
>
> I haven't tested it but offhand I call it inaccurate :)
> I had only cursory look at it but: regexes are way underpowered to do the task and thus false positives and false negatives are unavoidable.
>
> Just throw in more templates and mixins and it will fail ;)

As i said: it isn't perfect yet. ;) But maybe one of you could help me.
And regex are the only way i know to scan code.
And yes i know, sometimes warnings for unused variables _would_ be annoying but then we have to discuss if a new compiler switch is useful.
IMO it is, but IMO a shorthand like "?" for not null types is similar useful.
Maybe i expect to much, maybe i should use such programms only by myself.
July 30, 2012
On 31-Jul-12 00:45, Namespace wrote:
> On Monday, 30 July 2012 at 20:06:42 UTC, Dmitry Olshansky wrote:
>> On 31-Jul-12 00:02, Namespace wrote:
>>> BTW: Has anyone test my detector and could give me some suggestions or
>>> critism?
>>
>> I haven't tested it but offhand I call it inaccurate :)
>> I had only cursory look at it but: regexes are way underpowered to do
>> the task and thus false positives and false negatives are unavoidable.
>>
>> Just throw in more templates and mixins and it will fail ;)
>
> As i said: it isn't perfect yet. ;) But maybe one of you could help me.
> And regex are the only way i know to scan code.
> And yes i know, sometimes warnings for unused variables _would_ be
> annoying but then we have to discuss if a new compiler switch is useful.
> IMO it is, but IMO a shorthand like "?" for not null types is similar
> useful.

Adding new language features is at best problematic at this point.

> Maybe i expect to much, maybe i should use such programms only by myself.

I see no problem with a special D tool (a-la lint) that will check this and other possible problems.

-- 
Dmitry Olshansky
July 30, 2012
On 7/30/12, Namespace <rswhite4@googlemail.com> wrote:
> BTW: Has anyone test my detector and could give me some suggestions or critism?
>

I've tried it out and it didn't find any unused variables, but I doubt this is true, I'm not very tidy when it comes to using variables. I do use a lot of templates so maybe the script bailed on those.
1 2 3 4
Top | Discussion index | About this forum | D home