bearophile wrote:
Ary Borenszweig:
How is python safer than D in that sense?
This is correct D code:
class Foo {
int x;
this() { x = 5; }
}
void main() {}
In Python "self." is always needed to refer to the attribute, and "x" refers to
the argument (or a global name, but then you need a global statement). So the eyes of Python
programmers are trained to remember such difference.
In D the "this." is optional, even in the constructor. So it's more ambiguous,
you have to look at the signature of the method you are inside (or the IDE has to color
your names differently).
Bye,
bearophile
Now I understand. So you suggest to forbid having an argument name that
matches an attribute name? Or require this. for attribute access?