There is no trick as such, as you saw dict is written in normal erlang. Although some effort has been made to ensure that as much as possible of the "old" dict is reused without copying, only the bits which contain new data are actually created new. One way of doing this is to break up the big table into a tree of smaller bits. There are a few other small tricks which help to improve garbage collection, but they are still all normal erlang.<br>

<br>Gb_trees and array use the same techniques of building trees so that only small bits need to be rebuilt.<br><br>Robert<br><br><div class="gmail_quote">2009/4/24 Dmitry Kakurin <span dir="ltr"><<a href="mailto:dmitry.kakurin@gmail.com">dmitry.kakurin@gmail.com</a>></span><br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Newbie question.<br>
When I append something to a dictionary a new copy is returned and the<br>
old copy is still valid (the functional nature of Erlang).<br>
I've assumed that there is some kind of clever trick to create an<br>
appearance of copy without actual data duplication.<br>
However after looking at dict sources it looks like it does a simple copy.<br>
Am I missing something or there is no trick?<br>
<br>
- Dmitry<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br>