@property - take it behind the woodshed and shoot it?
Adam Wilson
flyboynw at gmail.com
Thu Jan 24 13:51:56 PST 2013
On Thu, 24 Jan 2013 13:45:44 -0800, Adam D. Ruppe
<destructionator at gmail.com> wrote:
> 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
Right, this conversation is about removing @property, which invalidates
your argument by turning the data into a function, which is what we want
to avoid. Also you might want to run your examples before posting them.
t.baz() is NOT an error, which incidentally why the ambiguities I
mentioned exist and need to be quashed.
--
Adam Wilson
IRC: LightBender
Project Coordinator
The Horizon Project
http://www.thehorizonproject.org/
More information about the Digitalmars-d
mailing list