Wish: Variable Not Used Warning
Koroskin Denis
2korden at gmail.com
Wed Jul 9 04:58:13 PDT 2008
On Wed, 09 Jul 2008 15:26:54 +0400, Manfred_Nowak <svv1999 at hotmail.com>
wrote:
> Koroskin Denis wrote:
>
>
>> void connect(unused int timeout)
> [...]
>> connection.connect(0); // I don't care, since it is immediate
>> anyway
> [...]
>> and then refactor your code
>
>
>
> In which way is this type of coding better than preparing for
> overloading `connect':
>
> void connect(){
> // ...
> }
>
> void connect( int timeout){
> // ...
> this.connect();
> }
>
> and then calling
>
> > connection.connect(); // immediate connection
>
>
>
> In addition: why is it good to be forced to refactor?
>
> -manfred
You asked an example, I provided one. There is another one:
class Node
{
private Node parent;
Node getRoot() {
Node p = parent;
while (parent !is null) {
parent = parent.next;
}
return parent;
}
}
Actually, getRoo() isn't supposed to modify this.parent, but it does by
accident (say nothing about const, please!). In my code, I was going to
modify local variable, but not a member. Local variable p was defined, it
has value assigned but it's _not_ used. Compiler could warn me that I
don't use it, and it would help to detect a problem.
More information about the Digitalmars-d
mailing list