On 11/24/2013 9:45 AM, Andrei Alexandrescu wrote:
Sorry, I misread the example - thought it's a function local variable. I'm not
sure whether shadowing globals or members would be a good idea. gcc has a -W
flag for that, and someone tried to turn it on at Facebook but with debatable
results. We ended up not using that warning.

Shadowing globals is definitely a bad idea. Shadowing members, it's debatable. In any case, I don't think it is some sort of terrible bug generator. In fact, I'll often write:

struct S {
    int m;
    this(int m) { this.m = m; }
}

because I like to make it clear I am initializing m. I find code like this to be unduly wretched:

struct S {
    int m;
    this(int _m) { m = _m; }
}

Reply via email to