@property on free function for UFCS?
Timon Gehr via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jun 14 09:21:39 PDT 2015
On 06/14/2015 05:50 PM, ketmar wrote:
> On Sun, 14 Jun 2015 12:26:52 +0000, rcorre wrote:
>
>> Suppose I have a function defined like so:
>>
>> void foo(int i) { }
>>
>> intended to be called like:
>>
>> 5.foo
>>
>> Should it be labeled with @property?
>> Or is @property only for true member functions?
>
> only if you plan to use it like `foo = 5;`.
You can use it like that anyway.
> i.e. exactly like field variable.
struct S{
void delegate() dg;
}
int main(){
S s;
s.dg=(){ writeln("!"); };
s.dg();
}
Now show me the UFCS way.
> compiler will not complain, but putting `@property` here is
> stylistically wrong.
>
It's neither wrong nor right.
More information about the Digitalmars-d-learn
mailing list