Referential transparency

Note: This page is new / WIP.

In 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:

Comments, suggestions and questions and are always welcome.