Redundancies often reveal bugs

JimBob jim at bob.com
Fri Oct 1 00:19:41 PDT 2010


"bearophile" <bearophileHUGS at lycos.com> wrote in message 
news:i83cil$2o02$1 at digitalmars.com...
>
> situations like x=x; reveal true bugs like:
>
> class Foo {
>    int x, y;
>    this(int x_, int y_) {
>        this.x = x;
>        y = y;
>
>    }
> }

I get hit much more often by somthing like this....

class Foo {
   int m_x, m_y;
   this(int x, int y)
   {
       int m_x = x;
       int m_y = y;
   }
}

I dont know if it is, but IMO it really should be an error to declare local 
variables that hide member variables.

 




More information about the Digitalmars-d mailing list