News for hackers. Stuff that matters.
Re:Why Const Sucks by abacate on Monday March 05, 2018 @08:09PM (#16526091)
> D's const is also transitive, meaning that if something is const, then everything it contains or refers to is also const. If D code has the equivalent of const vector<T*>, then not only is the container treated as const, but the elements are as well.

And that is not necessarily what the programmer wants.

There are a number of uses for a constant vector and non-const objects. Adding "const" in front of "T" should make everything constant, but just assuming everything is constant does not allow one to have non-const objects.

Unless there is a way to override this, it looks like a severe limitation in the language.

There are no comments on this comment yet.