Question regarding structural sharing, records, and maps

2011-07-29 Thread Trenton Strong
Hi all, this is my first post. I'm currently building a tree data structure (quadtree to be exact) while doing some exploratory game server programming using Clojure. This tree will end up with a lot of entities stored in the nodes, whose positions determine which node they end up in. As game

Re: Question regarding structural sharing, records, and maps

2011-07-29 Thread Ken Wesson
On Thu, Jul 28, 2011 at 11:59 PM, Trenton Strong trenton.str...@gmail.com wrote: 1.) Does structural sharing play well with nested structures? With a tree whose nodes are represented by nested maps, if a leaf node is updated with new data, will structural sharing efficiently represent the new

Re: Question regarding structural sharing, records, and maps

2011-07-29 Thread Michael Gardner
On Jul 28, 2011, at 10:59 PM, Trenton Strong wrote: So far, I have settled on just using a single ref wrapping the root node of the tree with all update functions acting on that ref via dosync. An atom would be more appropriate, unless you're coordinating updates to the tree with updates to

Re: Question regarding structural sharing, records, and maps

2011-07-29 Thread Trenton Strong
On Jul 29, 8:58 am, Michael Gardner gardne...@gmail.com wrote: An atom would be more appropriate, unless you're coordinating updates to the tree with updates to some other ref. Ah, for some reason that didn't occur to me, thanks. Since the tree in this case acts as a supporting index on

Re: Question regarding structural sharing, records, and maps

2011-07-29 Thread Trenton Strong
On Jul 29, 4:38 am, Ken Wesson kwess...@gmail.com wrote: Yes. In fact this should work with records, too -- all the native fields of the record need to be copied for each version, but most will typically be pointers and most of those will typically be to existing objects. Only the ones that

Re: Question regarding structural sharing, records, and maps

2011-07-29 Thread Ken Wesson
On Fri, Jul 29, 2011 at 4:33 PM, Trenton Strong trenton.str...@gmail.com wrote: Thanks for clearing that up. ... Thanks for taking the time to craft such a thoughtful reply, it is really helpful. You're welcome. -- Protege: What is this seething mass of parentheses?! Master: Your father's