Re:Why Const Doesn't Make C Code Faster
by worik on Monday August 19, 2019 @06:01PM
(#20742226)
Cast away const. One of the many reasons I gave up on C++.
What is const if it can be cast away?
[ Parent
| on HN ]
const should have been renamed to readonly, because that's what it means. It means that a variable only has readonly access to a value, but it is possible that another variable has write permissions, and so a compiler can not assume that just because one variable has readonly permission, that all variables have readonly permission except for in very limited circumstances.
readonly was the original proposed name, if I remember my D&E [0] correctly. Bjarne outlined in that book why he went with const instead, but I forget why off the top of my head. I guess it's tine for a re-read!
[0] The Design and Evolution of C++