On 16/02/16 12:31, Guillaume Piolat wrote:
I'm trying to say it politely.
D2 const story is more complicated than its competitors.

Both D1 "final" and C++ const always felt more useful and practical to
me that the whole D2 immutable/const/inout thing. The current scheme
seems to have marginal value in practice, lots of complexity, and is
harder to use well (Unqual, inout) etc. Constructors can break it. I
don't know why we should be that happy about our constness, maybe
someone can explain.


Seconded. It is one of the main tools I was using in C++ to avoid introducing bugs that I find completely unusable in D.

I've tried to introduce it into code I'm writing. I'm used to such things being a problem to add later for code that was not written this way in advance. That's the case in C++ too. Here, however, there are many cases where I simply couldn't get it to the finish line. Between not being able to have head const, needing to mutate vars in a const object (a la refcount) and the compiler deciding functions are pure, I often end up facing a problem where I say "okay, forget it".

And that's a real shame. We have at least one case where we're introducing runtime checks to make sure no one is accidentally changing a global var put there for reference, where declaring it const would have provided compile time assurance that we're okay.

Shachar

Reply via email to