Jakob Ovrum:

Value types with no indirection are implicitly convertible to immutable.

-----------
void main()
{
    int a = 2;
    immutable int b = a;
}
-----------

And far more, even with immutable reference types, in this program 'a' has to be immutable, no just const:


int[] foo(immutable int[] a) pure {
    return a.dup;
}
void main() {
    immutable b = foo([1, 2]);
}


There is the desire to extend this idea a bit more, I think Hara has something on this.

Bye,
bearophile

Reply via email to