Definition - What does Referential Transparency mean?
Referential transparency is a property of a specific part of a program or a programming language, especially functional programming languages like Haskell and R. An expression in a program is said to be referentially transparent if it can be replaced with its value and the resulting behavior is the same as before the change. This means that the program's behavior is not changed whether the input used is a reference or an actual value that the reference is pointing to.
Techopedia explains Referential Transparency
Referential transparency has its roots in analytical philosophy, which is a branch of philosophy that studies natural language constructs, arguments and statements based on the methods of mathematics and logic and has little to do with programming, although it has been adopted by computer scientists.
The concept is simple, the "referent," the thing that an expression refers to, can be used to substitute the "referrer" without changing the meaning of the expression. For example, the statement "Luke's father is an evil man," "Luke's father" references "Darth Vader" in Star Wars lore. So the statement is referentially transparent since "Luke's father" can be replaced at any time with "Darth Vader" and the statement would not change in meaning. However, in the statement "the audience did not know until 'The Empire Strikes Back' that Luke's father is actually Darth Vader" is not a referentially transparent expression since if "Luke's father" is replaced with "Darth Vader" the expression becomes "the audience did not know until 'The Empire Strikes Back' that Darth Vader is actually Darth Vader," which has an entirely different meaning.
In relation to programming, the concept is at first glance the same, but many philosophers disagree that the concept is implemented or carried over well in programming languages. But in general programming, this simply means that an expression can be replaced by its resulting value without having an effect on the program's behavior. For example, the function plusOne(x) simply adds one to whatever the value of x is, so if we know that x = 5 then we can safely replace the function with the value 6 in an expression which yields the same behavior when using plusOne(x). But if there is an external variable within the expression that is controlled externally, say in the function plusY(x) where Y within the function is externally controlled, the resulting behavior may not be the same — in this case this is not a referentially transparent expression.
Techopedia Deals: The Complete Computer Science Bundle
Join thousands of others with our weekly newsletter
The 4th Era of IT Infrastructure: Superconverged Systems:
Approaches and Benefits of Network Virtualization:
Free E-Book: Public Cloud Guide:
Free Tool: Virtual Health Monitor:
Free 30 Day Trial – Turbonomic: