{"id":175,"date":"2008-11-12T22:24:37","date_gmt":"2008-11-12T21:24:37","guid":{"rendered":"http:\/\/www.nobugs.org\/blog\/?p=175"},"modified":"2008-12-07T00:09:00","modified_gmt":"2008-12-06T23:09:00","slug":"why-do-they-call-it-referentially-transparent","status":"publish","type":"post","link":"https:\/\/www.nobugs.org\/blog\/archives\/2008\/11\/12\/why-do-they-call-it-referentially-transparent\/","title":{"rendered":"Why do they call it: Referentially transparent"},"content":{"rendered":"<p>I like understanding why things have the names that they do.  Two stories immediately spring to mind: the first is from Michael Faraday, which I wrote about <a href=\"http:\/\/www.nobugs.org\/blog\/archives\/2004\/10\/31\/words\/\">a while ago<\/a> whilst the second is from <a href=\"http:\/\/uk.youtube.com\/watch?v=0XgmrMZ0h54&#038;feature=related\">Richard Feynman<\/a> (at 6 mins).<\/p>\n<p>But back to the topic at hand! I know pretty well what the phrase &#8220;<strong>referentially transparent<\/strong>&#8221; means, at least in relation to computer programs.  It&#8217;s used to describe languages like Haskell where its always safe to replace a function like &#8220;foo()&#8221; by its return value (eg. 4) without changing the meaning of the program.  This is not something which you can do in general for languages like Java or C++ because functions, such as rand(), can potentially return different values each time you call them.  Also, if foo() contains printf statement, then the expressions &#8220;foo()&#8221; and &#8220;4&#8221; are different beasts, even if foo() does always return 4.<\/p>\n<p>So that&#8217;s the concept in question.  But why give it a name like &#8220;referentially transparent&#8221;?  What&#8217;s &#8220;transparent&#8221; about it?  And what &#8220;references&#8221; are we talking about?  (and how many metajokes could one make here?)<\/p>\n<p>The term &#8220;referentially transparent&#8221; seems to come from a certain <a href=\"http:\/\/books.google.co.uk\/books?ct=result&#038;q=quine+word+and+object+referentially+transparent&#038;btnG=Search+Books\">Mr Quine<\/a> philosophising about natural languages.  Let&#8217;s do an example, but first we need to look at two things.<\/p>\n<p>Firstly, take a sentence like &#8220;Andrew is bigger than a mouse&#8221; and erase the word &#8220;Andrew&#8221; to leave a hole &#8211; ie. &#8220;??? is bigger than a mouse&#8221;.  Philosophers call this a CONTEXT.  By filling the blanks in the CONTEXT you get back to a sentence.<\/p>\n<p>Secondly, think about the city of Edinburgh.  It&#8217;s a <em>thing<\/em>.  There are many ways to refer to it: &#8220;Edinburgh&#8221;, &#8220;Scotlands capital&#8221;, &#8220;the city at 56N 3W&#8221;.<\/p>\n<p>Now we&#8217;re ready to understand where the phrase &#8220;referentially transparent&#8221; comes from.<\/p>\n<p>The first word (&#8220;referentially&#8221;) is talking about the fact that &#8220;the Edinburgh thing&#8221; has many names.  There are many ways to REFERENCE that thing.<\/p>\n<p>You should read &#8220;transparent&#8221; to mean &#8220;doesn&#8217;t make a difference&#8221;.  If Microsoft rewrite Excel so that it runs faster but the UI is identical then you&#8217;d say the change was &#8220;transparent&#8221; to the users.  It&#8217;s &#8220;transparent&#8221; in the sense of &#8220;you can&#8217;t see it&#8221;.  It DOESN&#8217;T mean &#8220;you can see all the innards&#8221;, like a transparent PC case.<\/p>\n<p>Mr Quine says that a CONTEXT is &#8220;referentially transparent&#8221; if we can fill the hole with different names for the same underlying thing without affecting the meaning of the sentence.<\/p>\n<p>An example should make this clearer:<\/p>\n<ul>\n<li>&#8220;[Edinburgh] is bigger than a mouse&#8221; is true.<\/li>\n<li>&#8220;[Scotlands capital] is bigger than a mouse&#8221; is still true.<\/li>\n<li>&#8220;[The city at 56N 3W] is bigger than a mouse&#8221; is also true.<\/li>\n<\/ul>\n<p>So, the truth\/meaning of the sentence WASN&#8217;T AFFECTED by our choice of which of those three REFERENCES we used.  If we want to appear posher, we say that the context &#8220;(hole) is bigger than a mouse&#8221; is REFENTIALLY TRANSPARENT.<\/p>\n<p>The opposite case is when your choice of name does matter.  Quine describes those contexts as being REFERENTIALLY OPAQUE &#8211; ie. the changing names are important to the meaning of the sentence.  An example would be the context &#8220;??? has 9 letters&#8221;:<\/p>\n<ul>\n<li>&#8220;[Edinburgh] has 9 letters&#8221; is true.<\/li>\n<li>&#8220;[Scotlands capital] has 9 letters&#8221; is false.<\/li>\n<li>&#8220;[The city at 56N 3W] has 9 letters&#8221; is false.<\/li>\n<\/ul>\n<p>Therefore the context &#8220;??? has 9 letters&#8221; does change meaning depending on which name\/reference we use.  Why?  It&#8217;s because the sentence is now discussing the name itself rather than the thing.<\/p>\n<p>Actually, that&#8217;s not a great example because it&#8217;s not very clear what I meant by it &#8211; ie. in what &#8216;sense&#8217; I used the words.  If I was twisted, I could claim I intended to say that there was a sculpture exhibit in town which contained nine depictions of alphabet letters &#8211; in which case all three sentences would mean the same thing.  English is too ambiguous!  But the example is sufficient for the purpose of this blog posting.<\/p>\n<p>Now let&#8217;s get back to programming languages and see if we can make some connection between what &#8220;referentially transparent&#8221; means in haskell and what we&#8217;ve just seen it means in natural language.<\/p>\n<p>Errm, actually, maybe that&#8217;ll wait for another post.  I need to get a clearer understanding of why I believe haskell is referentially transparent in the above sense without putting the cart before the horse.  Eek, what if Simon Peyton-Jones has been lying to us all along!?  I mean, I can&#8217;t think of any way to break the RT rules, but that&#8217;s very different from a ground-up proof.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I like understanding why things have the names that they do. Two stories immediately spring to mind: the first is from Michael Faraday, which I wrote about a while ago whilst the second is from Richard Feynman (at 6 mins). But back to the topic at hand! I know pretty well what the phrase &#8220;referentially [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[12,9,11],"class_list":["post-175","post","type-post","status-publish","format-standard","hentry","category-general","tag-etymology","tag-haskell","tag-theory"],"_links":{"self":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts\/175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/comments?post=175"}],"version-history":[{"count":2,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts\/175\/revisions"}],"predecessor-version":[{"id":192,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts\/175\/revisions\/192"}],"wp:attachment":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/media?parent=175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/categories?post=175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/tags?post=175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}