Posted by azhenley 10/31/2025
[1] https://docs.astral.sh/ruff/rules/redefined-argument-from-lo...
[2] https://docs.astral.sh/ruff/rules/redefined-loop-name/
[3] https://pylint.pycqa.org/en/latest/user_guide/messages/warni...
int x = 3;
x = 4; // error!
int* p = &x;
*p = 4; // is that an error? f.c:4:8: warning: initializing 'int *' with an expression of type 'const int *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
4 | int* p = &x;
| ^ ~~
1 warning generated.The principle of reducing state changes and side-effects feels a good one.
Whether it's of any actual utility is debatable
- either it's transitive, in which case your type system is very much more complicated
- or it isn't, in which case it's a near useless liability
Naturally C++ runs with the latter, with bonus extra typing for all the overloads it induces.
Makes everything so much easier to reason about.
Hindsight's 20/20, of course. But still.
Well yea, that's what sane languages that aren't Python, C, and C++ do. See F# and Rust.