Referential transparency

In analytic philosophy and computer science, referential transparency and referential opacity are properties of linguistic constructions,[1] and by extension of languages. A linguistic construction is called referentially transparent when for any expression built from it, replacing a subexpression with another one that denotes the same value[2] does not change the value of the expression.[3][4] Otherwise, it is called referentially opaque. Each expression built from a referentially opaque linguistic construction states something about a subexpression, whereas each expression built from a referentially transparent linguistic construction states something not about a subexpression, meaning that the subexpressions are ‘transparent’ to the expression, acting merely as ‘references’ to something else.[5] For example, the linguistic construction ‘_ was wise’ is referentially transparent (e.g., Socrates was wise is equivalent to The founder of Western philosophy was wise) but ‘_ said _’ is referentially opaque (e.g., Xenophon said ‘Socrates was wise’ is not equivalent to Xenophon said ‘The founder of Western philosophy was wise’).

Referential transparency depends on the values associated to expressions, that is on the semantics of the language. So, both declarative languages and imperative languages can be referentially transparent or referentially opaque, according to the semantics they are given.

The importance of referential transparency is that it allows the programmer and the compiler to reason about program behavior as a rewrite system. This can help in proving correctness, simplifying an algorithm, assisting in modifying code without breaking it, or optimizing code by means of memoization, common subexpression elimination, lazy evaluation, or parallelization.

  1. ^ A linguistic construction (also called mode of containment, context, or operator) is an expression with holes.
  2. ^ Here a value is the denotation (also called meaning, object, or referent) of an expression, not the result of the evaluation process.
  3. ^ Quine, Willard Van Orman (1960). Word and Object (1st ed.). Cambridge, Massachusetts: MIT Press. p. 144. ISBN 978-0-262-17001-7.
  4. ^ Strachey, Christopher (1967). Fundamental Concepts in Programming Languages (Technical report). Lecture notes for the International Summer School in Computer Programming at Copenhagen. Also: Strachey, Christopher (2000). "Fundamental Concepts in Programming Languages". Higher-Order and Symbolic Computation. 13 (1–2): 11–49. doi:10.1023/A:1010000313106. S2CID 14124601.
  5. ^ Whitehead, Alfred North; Russell, Bertrand (1927). Principia Mathematica. Vol. 1 (2nd ed.). Cambridge: Cambridge University Press. p. 665. ISBN 978-0-521-06791-1.

© MMXXIII Rich X Search. We shall prevail. All rights reserved. Rich X Search