<div dir="ltr">On Thu, Sep 8, 2011 at 01:56, Zhi-Qiang Lei <span dir="ltr">&lt;<a href="mailto:zhiqiang.lei@gmail.com">zhiqiang.lei@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
When (&#39;f&#39; : &quot;oo&quot;) ++ &quot;bar&quot; becomes &#39;f&#39; : (&quot;oo&quot; ++ &quot;bar&quot;) and then becomes &#39;f&#39; : (&#39;o&#39; : (&quot;o&quot; ++ &quot;bar&quot;)), we still need &#39;f&#39;, don&#39;t we?</blockquote>
</div><br>Haskell lists are singly-linked lists, not arrays or double-linked lists or etc.  Once we&#39;ve evaluated past a given &quot;:&quot;, there is no way to go back to what precedes it; it&#39;s no longer reachable (unless the caller, who has been passed the earlier part, is holding onto it) and the garbage collector will reclaim it.<div>
<br></div><div>Put slightly differently:  as you&#39;ve phrased it, evaluation would expand each element but always start stepping into it from the very start.  That&#39;s not what happens; as the evaluator steps through the list, it throws away its reference to the earlier part completely.  So it never becomes &#39;f&#39; : (&#39;o&#39; : (&quot;o&quot; ++ &quot;bar&quot;))) because when the evaluator is at the &#39;o&#39; it has completely forgotten about the &#39;f&#39;.  It&#39;s got &#39;o&#39; : (&quot;o&quot; ++ &quot;bar&quot;) and any remaining reference (if there is one) to the &#39;f&#39; is held by something else.<br>
<div><br></div><div><div>-- <br>brandon s allbery                                      <a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a><br>wandering unix systems administrator (available)     (412) 475-9364 vm/sms<br>
<br>
</div></div></div></div>