const challenge
Walter Bright
newshound1 at digitalmars.com
Fri Feb 1 23:37:19 PST 2008
Sean Kelly wrote:
> For the rest, I am mostly waiting for 2.0 to get some of the features
> that I actually care about.
There is a lot more coming <g>. For example, I'm pretty excited about
the upcoming destructors for structs - they're an earthquake.
> Being a long-time C++ person one might
> think that I would consider const to be tremendously important, but
> experience with it has mostly made me feel that const is often more
> trouble than it's worth. In large projects, I more often find myself
> struggling against other programmer's inconsistent choices of how to
> apply const to their designs than I do benefiting from any apparent
> security that it provides. That said, I do think that the choice for
> transitive const in D will help tremendously, because it mandates
> consistency of design.
I suppose everyone knows how I feel about C++ const - it's the germ of a
good idea, but it's a feature that relies more on programmer convention
rather than language enforcement. This makes it more trouble than it's
worth.
D const, on the other hand, is driven by the idea that the semantics of
it must be reliable. The twin concepts of invariantness and transitivity
are the key. As we discussed, I think it results in a paradigm change,
rather than just sprinkling const through the declarations.
Invariant strings are one example of the transformative nature of it,
and it took me a long time to 'get it'. So I understand completely the
skepticism about it.
More information about the Digitalmars-d
mailing list