property / getProperty() / setProperty()

Ary Borenszweig ary at esperanto.org.ar
Sat Aug 1 11:38:46 PDT 2009


Rainer Deyke escribió:
> Ary Borenszweig wrote:
>> The "property" just signals that the function is a property. But it's
>> still a function and all of the previous rules that existed are still
>> valid.
> 
> My problem with the 'property' syntax:
> 
> Possibility 1: the property still acts like a function, so you can still
> do 'x.a()' when you mean 'x.a'.
> 
> Possibility 2: the property does not act like a function, so you can no
> longer get a delegate to the property getter.
> 
> Possibility 3: the property sometimes acts like a function and sometimes
> not, and you haven't defined the distinction.

None of those are correct. See Jarrett's post.

property {
   int x() { }
   int x(int a) { }
}

auto a = x; // OK
auto a = x(); // Wrong
x = 2; // OK
x(2); // Wrong



More information about the Digitalmars-d mailing list