I'm a little confused at this point why this doesn't work either:

const(Test) test = new Test();  // fine
test = new Test();                     // error


In C++, There is a clear distinction:

const Test *test1 = nullptr; // const before type
test1 = new Test();      // fine
        
Test *const test2 = nullptr; // const before identifier
test2 = new Test();      // error: test2 is readonly

Isn't there such a distinction in D?


I would have suggested that I got things backward, but this doesn't work either:

const Test test = new Test();
test = new Test(); // error: cannot modify const expression

Reply via email to