On 05/27/2013 05:24 PM, Francois Chabot wrote:

> If with immutable(Type)[], I can have a re-assignable reference
> to arrays of immutable data, I really should be able to have some
> form of syntactical equivalent for single instances. But there
> just doesn't seem to be one. Immutability for reference types
> seem to always apply both to the referenced data as well as the
> reference itself no matter what.

I agree.

I've been puzzled by this recently as well:

class C
{}

void main()
{
    const(C) c;
    c = new const(C);    // <-- compilation error
}

That is silly because not c, but what it refers to is const. It is supposed to be "turtles all the way down", not "turtles all the way up." :)

Somehow this issue feels even more strange on 'const' because 'const' doesn't bring any requirement on the data anyway. It only says that "I shall not mutate". It should be fine with everybody... The variable should be able to go ahead and not mutate something else. :)

Ali

Reply via email to