There is actually a good reason for this, and it includes the software development process itself.
Let's say you have a translation unit that calls some function with some numerical parameter, of course, you will make it a constant:
static const double epsilon = 1.e-3;
Nice, clean code. But now you understand that the epsilon that you installed is not so good, and you need the best. You really don't have the right way to determine what it should be, so you go for the trial version and the error:
static const double epsilon = 1.e-4;
You are rebuilding your program. And this is still not good. If you change it again, you will have to wait for the build to complete, and this may take some time on some non-trivial projects. What to do?
Well, debuggers allow you to change the value of variables if they are in memory (and are not excluded, like true constants). So we do the following:
static double epsilon = 1.e-4;
Now we set a breakpoint somewhere in this file. And we can change epsilon without having to rebuild our program every time. We end up saving valuable development time. And we find the right meaning in timelessness.
Will we leave this not const ? Not. This is a constant, so we mark it as const before checking our code. Leaving it non-constant is the smell of code. There is no purpose for this.
Storyteller
source share