http://d.puremagic.com/issues/show_bug.cgi?id=9732
monarchdo...@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |monarchdo...@gmail.com --- Comment #3 from monarchdo...@gmail.com 2013-03-17 07:14:20 PDT --- (In reply to comment #2) > I think you are right because the .init state of a member may not be as simple > as one thinks. Although OuterStruct.inner must be known at compile time, it > may > have a non-trivial destructor that needs to be called: > > struct Inner > { > ~this() > { > // ... not-trivial destructor ... > } > > // ... > } > > struct OuterStruct > { > Inner inner = Inner(specialInitValue); // <-- compile-time .init > > this(int i) > { > this.inner = Inner(i); // <-- further assignment > } > } > > Blitting the rvalue on top of OuterStruct.inner would not be right in that > case. I really don't think that's a problem. If anything, the default value should NOT be destroyed in the constructor. After all, it hasn't really even been initialized yet. If anything, that's exactly how "aggregate construction" works: postblit each value over the current fields, but DON'T destroy the fields: //-------- import std.stdio; struct Inner { int i; this(this){} //Postblit implies destruction of this. ~this() { writeln(i); } } struct Outer { Inner inner = Inner(1); // <-- compile-time .init } void main() { auto inner = Inner(2); { writeln("****"); auto outer = Outer(inner); // Overwrite with postblit, but don't call destructor. writeln("****"); } { writeln("****"); auto outer = Outer(inner); // Overwrite with postblit, but don't call destructor. outer.inner = inner; // Call postblit, destroying previous state. writeln("****"); } } //-------- **** **** //Notice no destroyer called here 2 //This is outer's destroyer destroying its inner **** 2 //This is our second blit. **** 2 //This is out second outer destroyer's destroying its inner 2 //This is our inner's destroyer //-------- So yeah, my conclusion is: destroyers are not a problem to this proposal. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------