<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Why do they call it: Referentially transparent (II)</title>
	<atom:link href="http://www.nobugs.org/blog/archives/2008/11/12/why-do-they-call-it-referentially-transparent-ii/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nobugs.org/blog/archives/2008/11/12/why-do-they-call-it-referentially-transparent-ii/</link>
	<description>Thoughts of a software engineer</description>
	<lastBuildDate>Fri, 12 Mar 2010 14:56:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Anthony Bailey</title>
		<link>http://www.nobugs.org/blog/archives/2008/11/12/why-do-they-call-it-referentially-transparent-ii/comment-page-1/#comment-44000</link>
		<dc:creator>Anthony Bailey</dc:creator>
		<pubDate>Fri, 14 Nov 2008 00:10:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.nobugs.org/blog/?p=177#comment-44000</guid>
		<description>Thanks for the clarification/explanation.

So far as I can see, then, referential transparency is guaranteed in a &quot;pure&quot; functional programming language (&quot;stateless&quot;, &quot;side-effect free&quot;, however you want to phrase it.)</description>
		<content:encoded><![CDATA[<p>Thanks for the clarification/explanation.</p>
<p>So far as I can see, then, referential transparency is guaranteed in a &#8220;pure&#8221; functional programming language (&#8221;stateless&#8221;, &#8220;side-effect free&#8221;, however you want to phrase it.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://www.nobugs.org/blog/archives/2008/11/12/why-do-they-call-it-referentially-transparent-ii/comment-page-1/#comment-43968</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Thu, 13 Nov 2008 08:51:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.nobugs.org/blog/?p=177#comment-43968</guid>
		<description>In other words, the &quot;seed of explicit value&quot; is the global state - naturally if you can reproduce that as input, the output of rand() will be the same. In this important respect, every possible program in every possible language is deterministic and side-effect free; languages just differ in their ability to let you see this through the type system (and hence equality of values).

What&#039;s interesting to me is that one can never be finished with capturing the idea of &quot;global state&quot; - we may expand the definition from &quot;stack contents&quot; to &quot;heap contents&quot; to &quot;sequences of inputs&quot; etc, but they&#039;re all approximations to something we can&#039;t possibly model in a type system (the entire state of the universe). In the presence of, say, ionizing radiation from outer space, there is no referential transparency in Haskell - a cosmic ray might make the same computation erroneously evaluate to two different values - but we&#039;ve decided that&#039;s rare and uncontrollable and hemce outside of the remit of the type system in exactly the same way that Java&#039;s type system doesn&#039;t care about the contents of memory locations and IO streams.</description>
		<content:encoded><![CDATA[<p>In other words, the &#8220;seed of explicit value&#8221; is the global state &#8211; naturally if you can reproduce that as input, the output of rand() will be the same. In this important respect, every possible program in every possible language is deterministic and side-effect free; languages just differ in their ability to let you see this through the type system (and hence equality of values).</p>
<p>What&#8217;s interesting to me is that one can never be finished with capturing the idea of &#8220;global state&#8221; &#8211; we may expand the definition from &#8220;stack contents&#8221; to &#8220;heap contents&#8221; to &#8220;sequences of inputs&#8221; etc, but they&#8217;re all approximations to something we can&#8217;t possibly model in a type system (the entire state of the universe). In the presence of, say, ionizing radiation from outer space, there is no referential transparency in Haskell &#8211; a cosmic ray might make the same computation erroneously evaluate to two different values &#8211; but we&#8217;ve decided that&#8217;s rare and uncontrollable and hemce outside of the remit of the type system in exactly the same way that Java&#8217;s type system doesn&#8217;t care about the contents of memory locations and IO streams.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Ingram</title>
		<link>http://www.nobugs.org/blog/archives/2008/11/12/why-do-they-call-it-referentially-transparent-ii/comment-page-1/#comment-43945</link>
		<dc:creator>Ryan Ingram</dc:creator>
		<pubDate>Thu, 13 Nov 2008 02:17:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.nobugs.org/blog/?p=177#comment-43945</guid>
		<description>&gt; Can I write a non-deterministic program in Haskell [...]?

Yes, via the wonder of monadic I/O.  In Haskell, the equivalent of rand() has the type &quot;IO Int&quot;.  One way to look at this value (see http://www.haskell.org/haskellwiki/IO_inside) is as a function (rand :: World -&gt; (World, Int)).

Now your haskell program, &quot;main&quot; has the type (IO ()), or rather (World -&gt; (World, ())).  Since the only value of the unit type () is () (leaving aside non-termination), we can handwavingly look at main as a function that takes the state of the world and returns a new state.  It is only through the observation of this function by the Haskell runtime that side effects and nondeterminism can happen as it transforms the input World into the output World.  main is the same function every time the program is run, but the contents of the World input to that function changes!</description>
		<content:encoded><![CDATA[<p>&gt; Can I write a non-deterministic program in Haskell [...]?</p>
<p>Yes, via the wonder of monadic I/O.  In Haskell, the equivalent of rand() has the type &#8220;IO Int&#8221;.  One way to look at this value (see <a href="http://www.haskell.org/haskellwiki/IO_inside)" rel="nofollow">http://www.haskell.org/haskellwiki/IO_inside)</a> is as a function (rand :: World -&gt; (World, Int)).</p>
<p>Now your haskell program, &#8220;main&#8221; has the type (IO ()), or rather (World -&gt; (World, ())).  Since the only value of the unit type () is () (leaving aside non-termination), we can handwavingly look at main as a function that takes the state of the world and returns a new state.  It is only through the observation of this function by the Haskell runtime that side effects and nondeterminism can happen as it transforms the input World into the output World.  main is the same function every time the program is run, but the contents of the World input to that function changes!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anthony Bailey</title>
		<link>http://www.nobugs.org/blog/archives/2008/11/12/why-do-they-call-it-referentially-transparent-ii/comment-page-1/#comment-43939</link>
		<dc:creator>Anthony Bailey</dc:creator>
		<pubDate>Wed, 12 Nov 2008 23:59:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.nobugs.org/blog/?p=177#comment-43939</guid>
		<description>I agree that especially once one has seen its history, &quot;referentially transparent&quot; is a fairly awful name for the property of programming languages that we are talking about. What is a better name? &quot;Substitutive&quot;?

I understand that the &quot;pure functional&quot; i,e, &quot;side-effect free&quot; nature of Haskell is enough to guarantee most of expression substitutivity - but how does it deal with your &quot;rand()&quot; example? Can I write a non-deterministic program in Haskell, or do I always end up writing &quot;roll the dice, using a seed of explicit value x to prime a deterministic random number generator&quot;?</description>
		<content:encoded><![CDATA[<p>I agree that especially once one has seen its history, &#8220;referentially transparent&#8221; is a fairly awful name for the property of programming languages that we are talking about. What is a better name? &#8220;Substitutive&#8221;?</p>
<p>I understand that the &#8220;pure functional&#8221; i,e, &#8220;side-effect free&#8221; nature of Haskell is enough to guarantee most of expression substitutivity &#8211; but how does it deal with your &#8220;rand()&#8221; example? Can I write a non-deterministic program in Haskell, or do I always end up writing &#8220;roll the dice, using a seed of explicit value x to prime a deterministic random number generator&#8221;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://www.nobugs.org/blog/archives/2008/11/12/why-do-they-call-it-referentially-transparent-ii/comment-page-1/#comment-43936</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Wed, 12 Nov 2008 22:53:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.nobugs.org/blog/?p=177#comment-43936</guid>
		<description>Oh, right, well, here we go then. &quot;Type&quot; is exactly what you&#039;re getting at with the phrase &quot;kind of name&quot;, I guess, in a roundabout kind of way. sqrt is a function from, say, reals to reals, whereas rand is a function from global states to reals; you can&#039;t just replace &quot;evaluate rand()&quot; with &quot;the result of evaluating rand()&quot; because the result (a real) doesn&#039;t &quot;take a state&quot;, so it can&#039;t even begin to be equal. That&#039;s the important difference between the &quot;names&quot;.

I suppose the whole point of types is to codify this notion of &#039;&quot;names&quot; and &quot;underlying things&quot;&#039;. Non-RT languages kind of blind you to this because they make you treat computations as different kinds of things to values (for the reasons you describe here), but that&#039;s a kludge that&#039;s acting to obscure reality, i.e. that computations are values.

I&#039;ll shut up now.</description>
		<content:encoded><![CDATA[<p>Oh, right, well, here we go then. &#8220;Type&#8221; is exactly what you&#8217;re getting at with the phrase &#8220;kind of name&#8221;, I guess, in a roundabout kind of way. sqrt is a function from, say, reals to reals, whereas rand is a function from global states to reals; you can&#8217;t just replace &#8220;evaluate rand()&#8221; with &#8220;the result of evaluating rand()&#8221; because the result (a real) doesn&#8217;t &#8220;take a state&#8221;, so it can&#8217;t even begin to be equal. That&#8217;s the important difference between the &#8220;names&#8221;.</p>
<p>I suppose the whole point of types is to codify this notion of &#8216;&#8221;names&#8221; and &#8220;underlying things&#8221;&#8216;. Non-RT languages kind of blind you to this because they make you treat computations as different kinds of things to values (for the reasons you describe here), but that&#8217;s a kludge that&#8217;s acting to obscure reality, i.e. that computations are values.</p>
<p>I&#8217;ll shut up now.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
