<div dir="ltr">On Wed, Jul 23, 2008 at 9:35 AM, Brad Roberts &lt;<a href="mailto:braddr@puremagic.com">braddr@puremagic.com</a>&gt; wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Wed, 23 Jul 2008, Bill Baxter wrote:<br>
<br>
&gt; On Wed, Jul 23, 2008 at 8:27 AM, Brad Roberts &lt;<a href="mailto:braddr@puremagic.com">braddr@puremagic.com</a>&gt; wrote:<br>
&gt; &gt; On Tue, 22 Jul 2008, Walter Bright wrote:<br>
&gt; &gt;<br>
&gt; By that do you mean something that&#39;s caused you actual trouble in C++<br>
&gt; projects? &nbsp;Or just something that keeps you awake at night worrying<br>
&gt; about the trouble it could cause? &nbsp;My feeling is that C++ const does a<br>
&gt; decent job in practice of preventing programmers from doing stupid<br>
&gt; things. &nbsp;On the other hand, if you&#39;re trying to go out of your way to<br>
&gt; be stupid... that&#39;s another matter. &nbsp;But for the most part, while it<br>
&gt; may be easy to circumvent const, it&#39;s not so easy to circumvent it<br>
&gt; accidentally. &nbsp;Useless for making compiler optimizations, yes, but<br>
&gt; fine for documenting the intent of code.<br>
&gt;<br>
&gt; --bb<br>
<br>
I mean has caused real trouble. &nbsp;I don&#39;t tend to make a lot of arguments<br>
based on theory. &nbsp;Primarily they&#39;re made from hard earned practice. &nbsp;C++<br>
does not make it possible (possibly too strong a statement, substitute<br>
easy if you can think of a loophole) to take an existing object that is<br>
poorly implemented for const-correctness and make that a contained object<br>
in another class that wants to behave const correctly. &nbsp;It&#39;s way way too<br>
easy to make a mistake and have constness end without seeing it.<br>
Transitivity is what most more junior developers _expect_ from c++&#39;s const<br>
system and it&#39;s not what they get.<br>
<br>
Secondarily, I _strongly_ value the benefit of const at the interface<br>
layer. &nbsp;That&#39;s even more important to me than the other half of constness.<br>
I love D&#39;s use of contracts and const (as well as in, out, and inout)<br>
playes a big role there.<br>
<br>
Yes, it&#39;s a matter of mismatched exepctations, and it is possible to use<br>
const correctly in c++, but to do so requires (like so much of c++)<br>
considerable care.<br>
<br>
To clarify, I&#39;ve spent much of my 20 year career as both a maintenance<br>
programmer and as a new code developer (roughly 50/50). &nbsp;I tend to<br>
volunteer for the cleanup projects because no one else is willing to do<br>
it. &nbsp;A lot of that time has been in multi-million line code bases that<br>
have been evolved extremely rapidly and haphazardly. &nbsp;Yes it&#39;s the fault<br>
of the code as much as the language, but a language that gave better<br>
guarantees would have prevented problems and made ongoing maintenance<br>
easier by having a trustable const system.<br>
<br>
Make sense?<br></blockquote><div><br>Yep.&nbsp; Thanks for sharing your experience.&nbsp; I&#39;m a researcher, so while I&#39;ve been at this for coding thing for 20 years too, I don&#39;t tend to play around with a lot of million-line code bases written by million-monkey junior programmers.&nbsp; I did do a short stint for a big, well-known software company once, and got my taste of million-monkey code, though.&nbsp; Scary stuff.&nbsp; They wanted me to modify some crufty parser to do some new tricks when there were absolutely no unit tests or example programs or even documentation to show me what it was supposed to be doing in the first place.&nbsp; I&#39;m amazed now that they didn&#39;t tell me to &quot;figure out this mess and document it first, writes some unit tests, then add feature X&quot; but instead they just wanted me to jump right in and throw more gasoline into the fire.&nbsp; Yikes.<br>
<br>--bb<br></div></div><br></div>