I’ve had some epic bugs from code which was relying on changing constants. Basically, there is no guarantee that the changes to the constant will propagate everywhere is used (especially true, from my observations, if the functions using the constant are inlined). The manual gives the impression that changing const values is frowned upon, but allowed. But from my experience, it should just be disallowed by the compiler. The behaviour of the code is nondeterministic.
4 Likes
I don’t think there is any reason why updating “constants” could not work, similarly to the solution of #265, it is just that it has not been implemented yet.
Declaring something const
would then imply that the compiler is free to treat it as such, and changing it (which would ideally happen only in development) would trigger recompilation.