Could someone explain this line:
In more complicated contexts, such as “+=”, a rewrite is performed by
doing both get and put.
Taken from: MSDN – Property
What do they mean by rewrite?Is it a compile-time rewrite or does it induce run-time overhead?As far as I know in release mode properties are compiled to the same thing, so they must have the same performance as getters/setters, right?
5
As you see in complete paragraph in MSDN page to that you referred, all work is done by compiler.
When the compiler sees a data member declared with this attribute on the right of a member-selection operator (“.” or “->”), it converts the operation to a get or put function, depending on whether such an expression is an l-value or an r-value. In more complicated contexts, such as “+=”, a rewrite is performed by doing both get and put.
By then it means that following line:
s.the_prop = 5;
n = s.the_prop;
compiled to:
s.putprop(5);
n = getprop();
A complicated case like:
s.the_prop += 5;
compiled to:
s.putprop(s.getprop() + 5);
I think it is not as complicated as they said in MSDN!