Fully transitive const is not necessary

Sean Kelly sean at invisibleduck.org
Wed Apr 2 10:26:33 PDT 2008


== Quote from Walter Bright (newshound1 at digitalmars.com)'s article
> Don Clugston wrote:
> > As far as I can tell, it's like any optimisation problem -- it's only
> > 5-10% of the code that matters: it's only necessary to use multiple
> > cores efficiently in a small fraction of the code (obviously the entire
> > code needs to be correct). So I'm a little uneasy about arguments for
> > const based on efficiency concerns -- there are many opportunities to
> > worry about stuff which is ultimately irrelevant. I hope that's not
> > happening here.
> Although better code generation is a positive consequence of const, and
> is worth mentioning, it isn't the motivation for it.
> What const and transitive const achieves is more reliable and more
> demonstrably correct code, which will indirectly improve productivity.

I agree that transitive const can achieve more demonstrably correct code
but I don't think it follows that this will necessarily improve productivity.
My experience with const in C++ is that it actually reduces productivity
because I spend more time dealing with the misapplication of const than
I gain from whatever bugs the application of const may have prevented.
In fact, in all my time as a programmer I can't think of a single instance
where I've encountered a bug that could have been prevented through
the use of const.


Sean



More information about the Digitalmars-d mailing list