4 ms·
Proposing making immutable by default in C or C++ doesn't make sense due to backwards compatibility reasons. New languages like Rust have easier time making bet
by shmerl 1y ago
Proposing making immutable by default in C or C++ doesn't make sense due to backwards compatibility reasons. New languages like Rust have easier time making better choices with immutable by default.
- loeg 1y agocpp2/cfront could plausibly do this, right? Except he doesn't want to: https://github.com/hsutter/cppfront/wiki/Design-note%3A-const-objects-by-default https://github.com/hsutter/cppfront/wiki/Design-note%3A-cons...
- shmerl 1y agoWell, if they are willing to break backwards compatibility, a lot of things can be improved, including this.
- NathanaelRea 1y agoThey could just add a "use immutable;" directive that you place at the top of your file.
- Pxtl 1y agoC# does this with the null hole. I wish more languages would take a versioning approach to defaults at the file-level.
- JonChesterfield 1y agoCould be a compiler flag. -const-by-default. Would probably mean you need to scatter mutable across the codebase to get it to compile, but I expect some people would like to have every local annotated as const or mutable.
- _flux 1y agoMaybe the new C++ profiles that are supposedly going to make C++ a safe language could do it.