4 ms·
If the object is immutable you can't really tell if it was passed by value or by reference. It becomes an implementation detail.
by ErikCorry 4y ago
If the object is immutable you can't really tell if it was passed by value or by reference. It becomes an implementation detail.
- eyelidlessness 4y agoYep, one of the theoretical promises of FP that’s totally vindicated (unless there’s a language bug, but they usually get this much right). And because you can’t tell, you don’t need to care. For folks working in imperative languages, you can achieve this same bliss by either not modifying your function parameters in the first place (hopefully this is obvious if you care about the distinction and find the language behavior ambiguous)… or by just doing whatever copy/clone/value transfer would be appropriate as a first step if you have good reason to modify the value of a parameter to your otherwise pure function.