On Thursday, 28 February 2013 at 14:55:06 UTC, angel wrote:
There _is_ reason.
You may, possibly, argue this reason is not important enough -
here you might be right or wrong, I don't know.
The point is a @property should behave as close as possible to
a real variable:
class A {
int field;
}
auto a = new A();
auto x = a.field = 3;
Now you 'upgrade' 'field' to a @property
class A {
int _field;
@property ??? field(int val) {
_field = val;
return _field = val;
}
}
auto a = new A();
auto x = a.field = 3;
The above line should behave _identically_ to the previous case.
Will it, if you define "@property char field(int val)" ?
Apparently no.
The current proposal is simpler and allow more. It surely does
allow to do crazy stupid things, but you can't really allow more
without allowing to do dumb things.