On 22-Jun-12 16:16, bearophile wrote:
Tobias Pankrath:I think it's good. In this special case, the compiler can see that you can't change array behind his back. That seems not to be true in general.But aren't int implicitly castable to immutable?
then every array is implicitly castable to tail immutable. int[] array = [1, 2]; foreach (ref immutable(int) x; array) { ... func(arr); // arr is mutable, thus func can change x // so x can be at most const } -- Dmitry Olshansky