Question about operations on class/struct properties
anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Aug 18 09:38:34 PDT 2014
On Monday, 18 August 2014 at 15:35:26 UTC, Uranuz wrote:
> 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.
This comes up every once in a while. I don't know if there are
any subtle problems, or if it's just that no one's found the time
to implement it.
> 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.
When you return a mutable reference, a setter doesn't make all
that much sense, as it can easily be circumvented, even
accidentally.
More information about the Digitalmars-d-learn
mailing list