@property (again)

John Colvin john.loughran.colvin at gmail.com
Thu Nov 21 06:11:52 PST 2013


On Thursday, 21 November 2013 at 13:28:01 UTC, Timon Gehr wrote:
> On 11/21/2013 02:04 PM, John Colvin wrote:
>>
>>
>> 3) properties decay to normal functions when they have their 
>> address taken
>
> No, why?

Sorry, I forgot to add:
5) parenthesis are enforced for all calls on all callables other 
than functions, including function pointers and delegates.

In combination with 3 this prevents any ambiguity when dealing 
with addresses of functions. Otherwise they become impossible to 
manipulate as they would evaluate to their result anywhere 
they're mentioned in code. Some examples of things working how I 
suggest:

@property auto f() { return 3; }
auto p = &f;
auto q = p;   //q is address of f
auto r = q(); //r is 3

auto g() { return &f; }

auto a = g(); //a is address of f
auto b = g;
assert(a is b);

@property auto z() { return &f; }
auto c = z; //c is address of f


More information about the Digitalmars-d mailing list