4 ms·
> but i just don't ever want to see an error like that Then, do not mark your variables as mutable. This error only happens if you use `let mut variable_name =
by arve0 7y ago
> but i just don't ever want to see an error like that
Then, do not mark your variables as mutable. This error only happens if you use `let mut variable_name = ...`
AFAIK, `let var`, e.g. immutable variables, behaves the same as in clojure.
- keymone 7y ago"anything that is legal according to compiler will eventually make it's way into the codebase" (approximately quoting Carmack here) default behavior should be safe and simple to use, dangerous behavior should be hard to reach and inconvenient to use.
- arve0 7y ago> dangerous behavior should be hard to reach and inconvenient to use I understand your point, but to me that is exactly the case. It requires the extra "mut" (harder to reach) and is inconvenient to use (more compiler errors). My point is; Rust gives you the choice. If you need mutability due to performance, or something like that, you can have it (at the cost of simplicity and convenience). Also, "dangerous behavior" is not allowed, in this example threads sharing mutable and immutable reference to the same object.
- keymone 7y agowe're at risk of splitting hairs now, but given that rust isn't describing itself as "functional immutable language" i posit that rust users will gladly reach for `mut` whenever they feel like it, while in clojure you will think ten times before using transients (i still haven't found myself in a situation where i'd need them).