Steven Schveighoffer wrote:
On Wed, 29 Jul 2009 10:16:33 -0400, grauzone <[email protected]> wrote:
Daniel Keep wrote:
Maybe the compiler could rewrite the above as:
auto t = a.b;
t.c = 3;
a.b = t;
Unless it can prove it doesn't need to. Same solution as to the op=
conundrum.
Yes! At least that's what the user wants.
The compiler has to detect, that the object was modified at all. (To
know whether it should generate code to write back the property.)
Would this make the compiler much complexer?
You also have to deal with nested properties:
a.b.c.d = 3;
turns to
auto t = a.b;
auto t2 = t.c;
c.d = 3;
t.c = t2;
a.b = t;
???
Yeah, I think this idea is no good. a.b.c.d.e.f = 3, results in one
gigantic mess, which the user might not want.
I don't want to type out that mess as a user either...
Design changes to avoid that mentioned mess would interfere with the
goal of abstraction (e.g. assume you have widget.position, now how do
you set only the x coordinate? yeah, split the property into position_x
and position_y. Result is you have more noise, and you can't use a Point
struct.)
As for the rest, I'm sure all of you will have figured it out after some
more ~500 postings.