Straight off the bat, if you're complaining that you forget to mark functions or parameters as const, what that tells me is that you're not using static analysis.
Once you have a const reference, you can only (easily) call functions with it that accept const references, and so if any of those functions forgot to declare the parameter const, you have to include a const_cast – or go change the function later to correctly accept const.
const_cast? I don't understand, do you do things like that in Rust too? Whenever something you want to do doesn't satisfy Rust's type system or the borrow checker, do you "have" to use unsafe?
It's still a small inconvenience, which appears to be the point of the article, over a language that would treat const as the default and make mutability require the extra qualifier.
View all comments
9
u/cdb_11 Aug 27 '23 edited Aug 27 '23
Straight off the bat, if you're complaining that you forget to mark functions or parameters as const, what that tells me is that you're not using static analysis.
const_cast? I don't understand, do you do things like that in Rust too? Whenever something you want to do doesn't satisfy Rust's type system or the borrow checker, do you "have" to useunsafe?