Immutable data not copied

Tomek Sowiński just at
Tue Dec 8 16:18:46 PST 2009

const(FAQ) says: "When doing a deep copy of a data structure, the  
invariant portions need not be copied."
I'm trying to imagine what code would benefit from such optimization.

immutable struct Large { whole lotta data... }

struct Other { Large l; }

void funkcja(Large s);  // no reference annotation on parameter, copied?
    Large t = s;   // copied?
    auto other = Other(s);  // copied?
    Other o = other;  // other.l copied?


More information about the Digitalmars-d-learn mailing list