Referential transparency
đ Wiki page | đ Last updated: Feb 5, 2022In a practical sense, the expression is referentially transparent if you can replace every occurrence of the expression with its value, and the result will be the same.
i.e. if the expression get_answer(0)
returns 42
, and you replace every occurrence of get_answer(0)
with 42
, then expression get_answer(0)
is referentially transparent.
Note that get_answer
ALWAYS must return the same output for the same input.
While theoretically, the referentially transparent function can be impure (i.e. it can create some irrelevant side effect in the process), the pure function must always be referentially transparent.
See also:
Ask me anything / Suggestions
If you find this site useful in any way, please consider supporting it.