More name hiding

Mehrdad wfunction at hotmail.com
Fri Aug 19 20:22:04 PDT 2011


On 8/19/2011 8:17 AM, Andrej Mitrovic wrote:
> It's not just globals. It's hiding fields as well:
>
> class A
> {
>      int x;
>      this()
>      {
>           int x; //<- hides this.x
>      }
> }
>
> I've had this happen during a cut/paste session, which happens when
> I'm refactoring my code.
I actually use this on PURPOSE -- I always use the 'this' pointer when 
referring to members anyway. It's a great way to avoid unnecessarily 
renaming x to things like x1, x_1, x_, _x, x0, x_0, this_x, my_x, myx, 
etc...

Even more common with constructor parameters and instance fields.


More information about the Digitalmars-d mailing list