Stepping back and looking at constness from another angle.
Walter Bright
newshound1 at digitalmars.com
Mon Jun 4 22:59:43 PDT 2007
Jarrett Billingsley wrote:
> I won't lie, I'm not fond of the changes that are being developed. Now that
> even my dear, sweet dynamic arrays are having their syntax changed to
> something like int[new], I figured I'd voice my concerns over it.
I answered a similar post from Charlie, but since the discussion seems
to be here instead, I'll repost here:
-----------------------
Actually, I quite empathize with your viewpoint. I worry that the final,
const, invariant thing is too complicated. But there are some mitigating
factors:
1) Just as in C++, you can pretty much ignore final, const, and
invariant if they don't appeal to you. I don't bother using const in my
C++ code.
2) The transitive nature of const means that there are a lot fewer
const's you have to write.
3) Using D's type inference capability, a lot fewer types (and their
attendant const's) need to be written.
4) It provides information that is actually useful to the compiler.
5) Scope has the promise of enabling reference counting to be far more
efficient than is possible in C++.
6) Working together, these features move us towards supporting the
functional programming paradigm better. FP is very important for the
future, as it is very adaptable to parallel programming.
7) They make interfaces much more self-documenting.
8) They can make automated code analysis tools more effective. Automated
code analysis is big business and is getting to be far more important as
security consultants are brought in to analyze code for correctness,
security, etc. Wall Street in particular is very interested in this stuff.
9) So far, in my work to make Phobos const-correct, it hasn't been the
annoyance I thought it would be.
More information about the Digitalmars-d
mailing list