Reddit: why aren't people using D?

Steven Schveighoffer schveiguy at yahoo.com
Tue Jul 28 06:17:27 PDT 2009


On Mon, 27 Jul 2009 21:14:10 -0400, Rainer Deyke <rainerd at eldwood.com>  
wrote:

> Benji Smith wrote:
>> For my money, the best solution is a simple "property" keyword as a
>> function modifier. Only functions with the "property" modifier would be
>> allowed to pose as fields (getters called without parens, setters called
>> using assignment syntax). But, in all other respects, they should act
>> just like functions.
>
> I like being able to distinguish between the property itself and its
> setter/getter function.
>
> For example, let's say 'y' is a property of 'x'.
>
> z = x.y; // Calls the getter.
> x.y = z; // Calls the setter.
> z = &x.y; // But what's this?  The setter, the getter, or the property
> itself?

This is a general problem with all overloaded functions.  The answer is  
that it's the first one declared.

You can specify it by declaring the type of z before assigning.

I think this might need some attention in general, not just for properties.

-Steve



More information about the Digitalmars-d mailing list