The Iron Rule #PLramble it is safe to mutate an object exactly when (you can pro...
bnuuy @bnuuy@mathstodon.xyz
The Iron Rule #PLramble
it is safe to mutate an object exactly when (you can prove) no one else is looking at it.
"no one else" may sound like it means some other thread (and it does), but it also applies to the same thread looking at the object through an alias without realizing it. (the latter is an aliasing bug, though classification can get a bit subjective here: if the code "knows" about the aliasing/the possibility of it, and is written to take it into account, it's not exactly a bug)
this rule applies in *every* programming language. some languages attempt to enforce it, though the amount and mechanism of enforcement varies.