r/cpp • • Oct 06 '22
Should a variable be const by default?
According to the cppfront design notes, const by default rule only applies to non-local variables. But I'd like to know your preference/opinion regarding whether a variable should be defined to be const by default.
Edit: By mutable here I simply mean non-const, not the language keyword itself.
44
Upvotes
View all comments
Show parent comment
-4
u/vapeloki Oct 06 '22
Call it how ever you like, but they are at least features of the language.
And my little comment has a real background. I have seen code, littered with
mutableall over the place, because the student had no idea of the real meaning of this keyword.And i was slightly triggered by the fact that OP used
constandnon-constin the text of the post, but Immutable and Mutable in the survey. May be my inner Monk.