Let’s take this off poor @pamelafox’s mentions, y’all. She’s suffering enough with this needless debate within her own company!
3: That the original author considered it questionable to mutate the variable.
-
-
4: And what are we gaining? In exchange for losing user intent, we gain a minor but noisy piece of metadata ...
-
5: that is trivial to see by scanning the code (is it mutated is the same as "is there an x= somewhere in the function?")
-
6: If your functions are too large for it to be quickly analyzable, consider smaller functions.
-
7/7: Your code will be clearer and you won't have given up an important source of user intent.
-
I’m guilty of using “const” everywhere I can out of habit, but I doubt it has really ever prevented a bug.
-
It also devalues the meaning of const when you wrote it for a reason ("don't change this module-level variable plz")
-
In rust that kind of change is a public API-breaking change so people are more intentional about it.
-
I really want const to mean "the author thought this variable shouldn't be mutated" not "it happened to not be mutated".
- 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.