3 ms·
> Caveat: for reference types, immutability is shallow (you cannot change the reference but you can mutate the reference content). “Shallow immutability” is no
by electrograv 8y ago
> Caveat: for reference types, immutability is shallow (you cannot change the reference but you can mutate the reference content).
“Shallow immutability” is not just a “caveat” — it’s a complete abuse of the word “immutability”.
If you can in-place modify the interior of a so-called immutable value in any way (possibly excepting code within some kind of “unsafe” blocks), it is by definition not immutable. Immutability is a pure, all or nothing kind of thing.
That you are trying to present immutability as synonymous with C++ style “const”ness perhaps reinforces the parents’ post that Nim is not friendly or even aware of the functional paradigm of programming.
But unlike others, I think it’s okay that it doesn’t support immutable variables. It certainly doesn’t outright condemn the language. However, let’s not pretend it’s something that it’s not.
- mratsim 8y agoNim const are compile-time constants, it's completely different from C++ const. I don't agree on immutability, just like you have shallow copy and deep copy, you have shallow immutability and deep immutability. Also functional programming also distinguish pure (Haskell, Idris, ...) and impure functional programming (Ocaml, ...). Allowing side-effect through reference doesn't mean that a language is hostile to functional programming. It just means that it does not enforce purity.