Arguments and attributes with the same name

Steven Schveighoffer schveiguy at yahoo.com
Thu Mar 4 08:19:06 PST 2010


On Thu, 04 Mar 2010 11:06:15 -0500, bearophile <bearophileHUGS at lycos.com>  
wrote:

> 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.

I think the point is, the statement x = x + 1; isn't any more or less  
ambiguous in D than it is in python.  There is a well-defined meaning (and  
in fact the same meaning).

However, your point that it should be more difficult to make such mistakes  
is a good one.  I just don't think it translates at all to "Python's way  
is better" :)

-Steve



More information about the Digitalmars-d mailing list