Hi Johan,<br>thanks for the quick answer!<br><br><div class="gmail_quote">2010/8/17 Johan Tibell <span dir="ltr">&lt;<a href="mailto:johan.tibell@gmail.com">johan.tibell@gmail.com</a>&gt;</span><br>      The second question is this: say I have some functions working with a data type, say a graph.<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


Some of them might want to change the graph and return a new graph as a result.<br>
If they change say only one graph node, it would be extremely bad for performance if the whole graph got copied<br>any time such a change takes place. Is the compiler smart enough to make the code only copy the parts<br>


that have changed (copying lazily, so to speak)? Is that even possible?<br></blockquote><div><br></div></div></div>Since the graph is immutable most of the nodes in the new graph are shared with nodes in the old graph. This is know as path copying and is everywhere persistent (&quot;immutable&quot;) data structures are used. Updating a data structure (e.g. a tree) typically requires O(log n) nodes to be copied.<br>
<font color="#888888">

<br></font></blockquote><div><br>So that means the compiler figures this out for my own data structures, or do I have to take care that copying is done this way?<br>Sorry for my ignorance, I&#39;m still learning :)<br> </div>
<br></div>