From: Jorgen Grahn on
["Followup-To:" header set to comp.lang.c++. Neither the Java nor the
comp.programming people want to read about const correctness, I'm sure.]

On Tue, 2010-07-20, Alexander wrote:
> Wherever I find something on the topic, these are considered positive.

Only these two, or do you include a number of other things under
"etc", unknown to us?

> Why? I only find it time-consuming. Could you respond (preferably on
> comp.programming) why it can be considered as such, but motivated,
> that is without responses like "it's good software engineering
> practice", "it's just better", etc...

Const specifically: a language feature I really like.

I guess you can say that it adds another dimension to the type system.
It's good for the same reasons that the rest of the static typing is
good. E.g. that we can have have Foo* and Bar*, not just void*.

You make more information about your intentions explicit, in the code,
for the benefit for the reader. And the compiler can check it.

> I'm a learner, and I think now
> is the best time to shape out practices and priorities.

Yes. For const, you don't really have a choice -- if you refuse to use
it, you'll be in constant conflict with other programmers working on
the code.

There are still, I think, old C programmers who reject const, but I
never heard of a C++ programmer who did.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
From: Esmond Pitt on
On 21/07/2010 1:50 PM, Lew wrote:
> Lew wrote:
>>> Don't be so sure. Java has 'final', which isn't exactly the same as
>>> 'const' but is similar
>
> Esmond Pitt wrote:
>> It's not really all that similar.

> No one is saying that 'final' and 'const' are the same. If you think
> that's my point, you haven't been reading my posts.

I don't. I think you are saying, several times, that they are similar. I
think they are really different.

> But they are similar

And here you are saying it again.

> insofar as both prevent
> change to the variable to which they're attached.

And no further. As I said, 'const' implies a great deal more than that.
So much more that I can't accept that they are 'similar'.