That is a… strange take.
Random example, imagine a variable that holds the time of the last time the user moved the mouse. Or in a game holding the current selected target of the player. Or the players gold amount. Or its level. Or health. Or current position.
In all those cases, the answer is to swap in a new variable and throw the old one away.
Legit question because i think I’m misunderstanding. But if its a const, how are you able to swap or replace it?
It’s only a const within a function. You can pass the value to another function and changing it as it’s passed. For example:
const int foo = 1
other_func( foo + 1)
In functional programming, you tend to keep track of state on the stack like this.