> Mutability > By default, variables are mutable. You can enable Immutable by Default mode using a directive. > //> immutable-by-default > var x = 10; > // x = 20; // Error: x is immutable > var mut y = 10; > y = 20; // OK Wait, but this means that if I’m reading somebody’s code, I won’t know if variables are mutable or not unless I read the whole file looking for such directive. Imagine if someone even defined custo…
Given an option that is configurable, why would the default setting be the one that increases probability of errors? For some niches the answer is "because the convenience is worth it" (e.g. game jams). But I personally think the error prone option should be opt in for such cases. Or to be blunt: correctness should not be opt-in. It should be opt-out. I have considered such a flag for my future language, which I name…
Example:
let integer answer be 42 — this is a constant
set integer temperature be 37.2 — this is a mutable
Or with the more esoglyphomaniac fashion cst ↦ 123 // a constant is just a trivial map
st ← 29.5 // initial assignment inferring float