All you said makes sense. If there is a direct connection between getter, setter and member than yes, returning it by reference is usually more convenient:

private T _member;
@property ref inout(T) member() inout {return _member;}

However, sometimes, there is no direct connection between field and mutators. Sometimes, it is calculated on the fly.

Date {
 ...
 @property auto hour() {return magic / someNumber;}
@property void hour(int newHour) {//complicated algorithm to set the hour.}

}

Now, assuming we have these two mutators, operators could be automagically implemented.

Date myDate;
myDate.hour += 4; //myDate.hour(myDate.hour() + 4)

Reply via email to