buzz
buzz copied to clipboard
Immutability by default
Should things be immutable (and private) by default?
str hello = "hello";
hello = "bye"; | fails
var str hello = "hello";
hello = "bye"; | ok
Hard big YES. Not only that "others" are doing it for years now, but enforcing immutability on a compiler level brings a lot of safety out of the box.
It may eventually lead to questions of "borrowing & ownership" (arrived in Swift 5.9, present in Rust since v1) but that's another subject.
Imho, this should be by default.
Enforcing immutability should be relatively straightforward. Implementing this should also pave the way to resolve/implement:
- #155
- #145
- #114
- #52
- #14
- #13