Who favors the current D1 situation?

Sean Kelly sean at invisibleduck.org
Fri Mar 7 11:57:06 PST 2008


== Quote from Walter Bright (newshound1 at digitalmars.com)'s article
> Bill Baxter wrote:
> >
> > Yes, they believe they need it.  Sure.  But I doubt many of them have
> > done any sort of analysis of how much it actually helps vs. how much it
> > complicates their code base.  I say this as someone who was totally sold
> > on C++ const for the first 10 years I used it.
> C++ const is not too useful anyway, as it is not transitive and not
> invariant. It's more of a convention.

I can't speak for anyone else, but my issue with C++ const had nothing to do with its reliability. (which I
felt was fine) but more to do with its impact on the semantics of the language, and more importantly, on
the maintainability of C++ code.  Personally, I found C++ const to be more of an obstacle to
maintainability than an aid.  This was for two reasons:

* The const features were applied inconsistently in the codebase, so changes sometimes required const
qualifiers to be reworked or new unrelated const methods to be added to suit the situation.

* C++ requires duplicate const and non-const member functions in many cases to switch on return
value, etc.  And duplicate code is never a good thing.

I suspect that transitive const in D will largely answer the first point however, and I remember there
being some talk of adaptable return types to handle the second point.  I'm not clear on how the latter bit
works though, and I think it's still yet to be implemented, correct?


Sean



More information about the Digitalmars-d mailing list