Hussein: If you ignore the ref for the moment, making any "change" to a map, or a map nested inside a map however many levels deep you wish, does not mutate the original map. Instead it creates a brand new map with the new set of keys and values. It is as if the original was copied, and the copy was modified, but it is implemented much more efficiently than that. For efficiency, this new map will usually share a lot of memory with the original one, but the original one and the new one are both in memory and accessible simultaneously, until and unless one is garbage collected, which would only happen after no other data structure references it any longer.
A ref effectively contains a pointer to one object at a time, and this pointer can change over time. If you want to be safe about concurrency, the ref should only ever point at an immutable data structure. "Modifying" the map pointed to by the ref merely means that the pointer is changed from pointing to one immutable map, to pointing at a different immutable map. Neither of the two maps becomes mutable as a result of this. Andy On Aug 10, 2012, at 9:21 AM, Hussein B. wrote: > Hi, > I have a ref type that wraps a map, this map is going to embed many nested > other maps. > According to immutability rules, what happens when: > A new nested map is updated (entry is removed or update) or even a new nested > map is added to the master map that is wrapped by ref type? > Thanks for help and time. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en