Properties: a.b.c = 3

grauzone none at example.net
Wed Jul 29 07:16:33 PDT 2009


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;

???



More information about the Digitalmars-d mailing list