On Tuesday, 16 October 2012 at 17:19:26 UTC, Jonathan M Davis wrote:
1. There is no generic way to deep copy stuff.

Could you elaborate on that a bit more?

How about a deep-assign operator? The compiler could implicitly define it at least for arrays and for structs that don't have mutable indirection:

struct MyStruct
{
    int _value;

    // implicit:
    ref MyStruct opDeepAssign(ref const MyStruct ms)
    {
        this = ms;
        return this;
    }
}

int[] array1 = [1, 2, 3];
int[] array2;
array2.opDeepAssign(array1); // array2 = array1.dup;

And there would be hasDeepAssign!T traits and whatnot.

Reply via email to