I don't know about syntax, but D sure needs first-class support of tail immutability.

Take this code for example:

---

immutable class C
{
        void foo()
        {
                //
        }
}

void main()
{
        auto c = new C();
        c.foo();
}

---

Compile it and get

Error: immutable method C.foo is not callable using a mutable object

Why? Because foo() is immutable and demands an immutable this reference. The C instance c is only tail immutable, which doesn't really count for anything. (So, "new C()" instead of "new immutable(C)()" is legal but pretty much unusable, it seems.)

But why should *any* function require an immutable reference, as opposed to a tail immutable reference? (Similarly for shared vs tail shared.)

Reply via email to