News for hackers. Stuff that matters.
Re:Why Const Sucks by signa11 on Monday March 05, 2018 @08:10PM (#16526098)
> All of this means that const actually provides zero guarantees about an object not being mutated (and even in the case where the object is directly constructed as const, that just means that it's undefined behavior when the object is mutated, not that the compiler actually protects against it being mutated).

if this is the only reason why author thinks that const is a problem, then it is all good. you can do the same thing in C as well. and ofcourse, if you do that, and break things, you get to hold all the pieces as well :)

probably a 'constexpr' semantics is what the author might be looking for ?

arne-mertz article on mutable, available here: https://arne-mertz.de/2017/10/mutable/, which imho, is another side of the const-coin, is quite good as well.

edit-001 : slight change.

Re:Why Const Sucks by gorgonical on Tuesday March 06, 2018 @01:16AM (#16527225)
I agree. Even extremely safe languages like Ada, which have found most of their use in safety-critical situations like in plane avionics and medical equipment, allow the programmer to do "unchecked conversions," the equivalent of a static_cast.

It would actually be insane for const to forbid the programmer from doing any of these things. A certain amount of a language and its features is to protect your program from other programmers, to communicate your idea and vision about the code. In that way, const is amazingly useful.

Re:Why Const Sucks by signa11 on Tuesday March 06, 2018 @11:01AM (#16529606)
> A certain amount of a language and its features is to protect your program from other programmers, to communicate your idea and vision about the code.

indeed ! language is about telling others (and yourself) about ideas that you want to express. c and c++ seems to be more suited for 'consenting adults' (oh dear) than anything else :)