@property

Jonathan M Davis jmdavisProg at gmail.com
Thu Jun 24 13:25:14 PDT 2010


Pelle wrote:

> As heard around these parts, a lot of people want property-style
> function calls to require the function to be declared with @property,
> like this:
> 
> @property foo(); //getter
> @property foo(int); //setter
> 
> foo; //getter
> foo = 13; //setter
> 
> While this seems quite reasonable, in practice I and others feel this
> leads to confusion, especially the getter part. Mostly when the getter
> has no setter counterpart. D also lets us call no-argument functions
> without parentheses today, so for this to happen a lot of code needs to
> change.
> 
> My suggestion is as follows; require @property for single-argument
> setters *only*. Make the silly writeln = 13; go away, but keep the "a b
> c".split;. This way, there can be no confusion about @property, and most
> code will go unchanged.
> 
> I hope this was not too late a suggestion. :)

I thought that the whole point of @property was that it enabled the 
property-style function calls with no parens and that functions not labeled 
with @property had to be called with parens.

- Jonathan M Davis


More information about the Digitalmars-d mailing list