On Saturday, 7 September 2013 at 22:57:40 UTC, Xinok wrote:
immutable
{
int[] arr = ...;
int[] arr2 = arr.dup;
sort(arr); // arr is still mutable
int[] arr2 = arr.dup;
reverse(arr2);
arr ~= arr2;
}
How do you stop mutable references escaping in functions called from the immutable block?
e.g.
int* p;
void foo(ref int x) { p = &x; }
void main()
{
immutable
{
int x = 1;
foo(x);
}
*p = 0;
}
