On Wednesday, 3 August 2016 at 08:09:41 UTC, qznc wrote:
On Tuesday, 2 August 2016 at 21:48:58 UTC, Mark Twain wrote:
global ImmutableArray!int Data;


MutableArray!int DataCopy = Data.Copy; // Creates a mutable copy of Data.
... Do work with DataCopy ...
Data.Replace(DataCopy); // Makes a copy of DataCopy.

I see the problem that you cannot compose this. Expand the example to two global arrays:

global ImmutableArray!int Data1;
global ImmutableArray!int Data2;

MutableArray!int DataCopy1 = Data1.Copy;
MutableArray!int DataCopy2 = Data2.Copy;
 ... Do work with DataCopy1 and DataCopy2 ...
Data1.Replace(DataCopy1);
// in between state is inconsistent => unsafe
Data2.Replace(DataCopy2);

I don't see this at all. What in between state are you talking about? Each object has it's own copy so no inconsistency is possible. If you are saying that Data1 and Data2 are suppose to be consistent as a pair, then your doing it wrong. You should combine them in to a single structure. The same problem would exist with other techniques. You have acted like the order of declaration matters but your example, given the information, can be written as

global ImmutableArray!int Data1;
MutableArray!int DataCopy1 = Data1.Copy;
//....
Data1.Replace(DataCopy1);


global ImmutableArray!int Data2;
MutableArray!int DataCopy2 = Data2.Copy;
//....
Data2.Replace(DataCopy2);





Reply via email to