I think there is something that I don't understand about concept of *properties*. I thing that property is sort of object attribute that belongs to it. Currently property considered as two functions: *get* and/or *set*. So we can do two sort of operations on concept that called *property*: *assign to it* and *read it*. If property doesn't return reference value all other manipulations are forbidden. A will illustrate it with example:

import std.datetime, std.stdio;

void main()
{
        auto date = Date(1991, 5, 7);
        //date.day += 5; //Not working
        //date.day++;  //Not working
        date.day = date.day + 1;
}

Because day property is of ubyte (not reference) type, we can only read it into some other variable or assign to it, but other other operations couldn't be done.

It is a common case when I want to increment, decrement or using some other 'op=' - operation, but it is not working and I get compile-time error. I always was thinking that

date.day++;
date.day -= 5;

Should be treated as:

date.day = date.day + 1;
date.day = date.day - 5;

if the were not oveloaded. So if we have get and set property methods I see that it could be calculated and this should working.

Of course I can define return value of get property as *ref* but in this case I don't understand how I should use it with *setter* method.

It's interesting to see any thinkings about it.

Reply via email to