#readwise
# Referential transparency

## Metadata
- Author: [[wikipedia.org]]
- Full Title: Referential transparency
- URL: https://en.wikipedia.org/wiki/Referential_transparency
## Highlights
In [computer science](https://en.wikipedia.org/wiki/Computer_science), referential transparency and referential opacity are properties of parts of [computer programs](https://en.wikipedia.org/wiki/Computer_program). **An [expression](https://en.wikipedia.org/wiki/Expression_(programming)) is called *referentially transparent* if it can be [replaced](https://en.wikipedia.org/wiki/Rewriting) with its corresponding value (and vice-versa) without changing the program's behavior**. This requires that the expression be [pure](https://en.wikipedia.org/wiki/Pure_function) – its value must be the same for the same inputs and its evaluation must have no [side effects](https://en.wikipedia.org/wiki/Side_effect_(computer_science)). An expression that is not referentially transparent is called referentially opaque. ([View Highlight](https://read.readwise.io/read/01gvqmzb5cegm65j4n9a7yz9ry))
---
In [mathematics](https://en.wikipedia.org/wiki/Mathematics), all function applications are referentially transparent, by the definition of what constitutes a [mathematical function](https://en.wikipedia.org/wiki/Function_(mathematics)). However, this is not always the case in programming, where the terms [*procedure*](https://en.wikipedia.org/wiki/Procedure_(computer_science)) and [*method*](https://en.wikipedia.org/wiki/Method_(computer_science)) are used to avoid misleading connotations. **A defining characteristic of [functional programming](https://en.wikipedia.org/wiki/Functional_programming) is that it only allows referentially transparent functions.** Other [programming languages](https://en.wikipedia.org/wiki/Programming_language) may provide means to selectively guarantee referential transparency. Some functional programming languages enforce referential transparency for all functions. ([View Highlight](https://read.readwise.io/read/01gvqn0axt91kza202ndv3dg8r))