4 ms·
"-Share data liberally by reference all over your code. -Try not to make functions side-effecting" Aren't those 2 points contradictory?
by hutzlibu 10y ago
"-Share data liberally by reference all over your code.
-Try not to make functions side-effecting"
Aren't those 2 points contradictory?
- rjeli 10y agono, the shared data is not modified
- Smudge 10y agoImmutable data is very easily shared.
- mywittyname 10y agoDoesn't "by reference" imply mutability and allow for side-effects (as opposed to by value, which cannot side-effects by design).
- AnimalMuppet 10y agoNo. 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.
- hutzlibu 10y agoOk, I understood "sharing data" as equal to read and write ...