Arguments and attributes with the same name
bearophile
bearophileHUGS at lycos.com
Thu Mar 4 08:06:15 PST 2010
Ary Borenszweig:
> But python doesn't do it either. Did you suggest the same thing to the
> python devs? :-)
:-)
Well, when I teach Python I give the advice of not using the same names for arguments and attributes. So it's a programming practice.
Here the situation in D is worse, because in Python there's always a "self." before attribute names, so there's no real ambiguity.
Python is the language I currently prefer, but it's not perfect, and every Python programmer knows it has some messy corners. Even Python programmers recognize that Python can enjoy some of the features D already has, like transitive immutability:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/7ef75c20d1be370d/
Or the scope exit:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/8c752e871801c223
Or the underscore inside number literals (many people want them, but Hettinger has said that normal Python programs have few literals, and such change requires too much big changes in the Python parser, so they have refused it).
I can show you other examples of messy things in Python, like the "confusion" between class instance attributes and class attributes (you can call class attributes even with an instance syntax, with the self).
Python was born to write scripts, not to write large multi-programmer applications. Later they have patched some holes, but some of the original more "relaxed" nature of Python shows still (Ruby is worse than Python regarding large multiprogrammer programs).
I have just filed the bug:
http://d.puremagic.com/issues/show_bug.cgi?id=3878
Bye,
bearophile
More information about the Digitalmars-d
mailing list