1
$\begingroup$

Referential transparency is a relatively new concept to me, but I understood that it means that a function will always give the same answer given the same arguments.

Would passing arguments by reference break this property somehow in a functional language?

$\endgroup$
2
  • 1
    $\begingroup$ DId you have something other in mind than "make all data immutable"? $\endgroup$
    – Pseudonym
    Aug 3 at 0:06
  • $\begingroup$ Yes, something like passing a variable as reference but consider it a const only in function's scope. $\endgroup$
    – Daniel
    Aug 3 at 3:32
3
$\begingroup$

The only way to observe a difference between pass-by-value and pass-by-reference would be to mutate the reference. But, since referential transparency precludes mutation, that is not possible.

So, in other words: in a functional language, it is actually impossible to tell the difference between pass-by-value and pass-by-reference. As a consequence, the language implementor is free to choose either, or maybe even both, depending on performance, personal preference, ease of implementation, or really any criteria they want.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.