Is doing something like:

auto someInstance = new immutable(SomeClass);

considered to be casting, where all bets are off, or is it supposed to be
safe?  If it's supposed to be safe,  below is an example of where it's not.
If it's supposed to be like casting, then what's a safe way of creating
immutable class instances?

import std.stdio;

uint[] array;

class A {
    uint[] AArray;

    this(uint[] inArray) {
        AArray = inArray;
    }
}

void main() {
    array = new uint[10];
    auto bar = new immutable(A)(array);
    writeln(bar.AArray);
    array[0] = 1;
    writeln(bar.AArray);
}

Reply via email to