4 ms·
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
by Kranar 7y ago
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.
- bstamour 7y agoreadonly 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++
- gpderetta 7y agoconst values are really const (i.e. immutable). Const references are actually readonly. Could have used different keywords of course.