@property - take it behind the woodshed and shoot it?

Adam D. Ruppe destructionator at gmail.com
Thu Jan 24 13:45:44 PST 2013


On Thursday, 24 January 2013 at 21:41:58 UTC, Adam Wilson wrote:
> The problem is that optional parens introduce ambiguity in 
> relation to what is a property versus a function from the 
> compilers prospective.

No, it doesn't.

struct Thing {
    int foo() { return 0; } // method
    int bar; // data field
    @property int baz() { return 0; } // data field
}

Thing t;
t.bar = 10; // this is a data field because it is
     // declared as "int bar" above,
     // not because I didn't use parens down here

t.foo; // this is a function call because t.foo is a function

t.baz; // this is a data field because i declared
        // "@property int" above, not because I left off parens 
here

t.bar(); // error, type int has no call method

t.baz(); // error, type int has no call method


More information about the Digitalmars-d mailing list