Hacker News new | ask | show | jobs
by Smudge 3668 days ago
Immutable data is very easily shared.
1 comments

Doesn't "by reference" imply mutability and allow for side-effects (as opposed to by value, which cannot side-effects by design).
No. In C++, for instance, you can share data either by a const reference (or pointer), or by a non-const reference (or pointer). The latter allows mutation; the former does not.

Now, that means that the language is not forcing you to share without mutability, because you can leave off "const". That is, you have to be disciplined. But if you put "const" on the reference, the compiler won't permit you to modify the data through that reference.