Immutability by default (opens in new tab)
Hello, Why does Zig not have immutability by default for slices/pointers? Currently: const s1: [] u8 = ...; → elemenst s1 points to can be mutated const s1: [] const u8 = ...; → elements s1 points to cannot be mutated (s1 can’t be reassigned to in both cases) My suggestion: why not the other way around? const s1: [] u8 = ...; → elemenst s1 points to cannot mutated const s1: [] var u8 = ...; → elements s1 points to can be mutated It feels safer to me: I often forget to make a pointer / slice i...
Read the original article