Re: opOpAssign on object properties

2017-01-08 Thread collerblade via Digitalmars-d-learn
On Sunday, 8 January 2017 at 21:50:12 UTC, Ivan Kazmenko wrote: On Sunday, 8 January 2017 at 18:23:34 UTC, collerblade wrote: [...] Hmm, right. The setter is not called, and it's by the spec. Which says that "a op= b" is rewritten as "a.opOpAssign !(op) (b)". Here: https://dlang.org/spec/op

Re: opOpAssign on object properties

2017-01-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 8 January 2017 at 18:23:34 UTC, collerblade wrote: On Sunday, 8 January 2017 at 10:03:50 UTC, Ivan Kazmenko wrote: On Sunday, 8 January 2017 at 09:22:12 UTC, collerblade wrote: [...] 1. If you want the member variable to change, naturally, you should provide a getter property whic

Re: opOpAssign on object properties

2017-01-08 Thread collerblade via Digitalmars-d-learn
On Sunday, 8 January 2017 at 10:03:50 UTC, Ivan Kazmenko wrote: On Sunday, 8 January 2017 at 09:22:12 UTC, collerblade wrote: [...] 1. If you want the member variable to change, naturally, you should provide a getter property which returns a reference to that variable: [...] yes i tried

Re: opOpAssign on object properties

2017-01-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 8 January 2017 at 09:22:12 UTC, collerblade wrote: How can i do opOpAssign with properties?? 1. If you want the member variable to change, naturally, you should provide a getter property which returns a reference to that variable: ref Point location() @property { return

opOpAssign on object properties

2017-01-08 Thread collerblade via Digitalmars-d-learn
hello guys, i would like to have properties with /= *= += -= operators. My code: struct Point { float x=0,y=0; this(float _x, float _y) { x=_x; y=_y; } //opassign for + //opopassign for += void opOpAssign(string op=="+")(in Point p) { x+=p.x; y+=p.y; } } class