@property

Pelle pelle.mansson at gmail.com
Thu Jun 24 13:21:37 PDT 2010


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


More information about the Digitalmars-d mailing list