5 ms·
> Both Go and Rust encourage single-assignment programming Go is probably the least "singe-assignment encouraging" of current languages. It does not provide an
by pron 12y ago
> Both Go and Rust encourage single-assignment programming
Go is probably the least "singe-assignment encouraging" of current languages. It does not provide any const/final mechanism for anything but compile-time constants, and does not allow the creation of immutable objects.
- Animats 12y agoRight. There's ":=" and "=", but no read-only enforcement on anything in Go other than compile-time constants. So you can write Go concisely in single-assignment style, but there's no enforcement.
- pron 12y agoNot only is there no enforcement by the language of the single-assignment style (as in Clojure, Erlang or Haskell), but there is even no way for the programmer to enforce a single assignment of a specific variable as in, say, Java and C++. So no single-assignment style and no single-assignment without the style in Go. Not only is mutability not discouraged, there's even no way to turn it off for specific types/variables. Go is fully in the JS/Python/Ruby camp when it comes to mutability.