@property Incorrectly Implemented?
John via Digitalmars-d
digitalmars-d at puremagic.com
Tue Sep 6 12:18:11 PDT 2016
Currently it seems that @property isn't implemented correctly.
For some reason when you try to get the pointer of a property it
returns a delegate for some reason. This just seems plain wrong,
the whole purpose of a property is for a function to behave as if
it weren't a function. There's also some inconsistencies in the
behavior, "get" is implemented one way and then "set" is
implemented another.
http://ideone.com/ZgGT2G
&t.x // returns "ref int delegate()"
&t.x() // ok returns "int*", but defeats purpose of
@property
&(t.j = 10) // shouldn't this return "ref int delegate(int)"
?
It would be nice to get this behavior fixed, so that it doesn't
become set in stone. I think returning a delegate pointer is not
what people would except nor is there really any use case for it.
More information about the Digitalmars-d
mailing list