When I here refs of refs, it's a code smell.  Granted, sometimes they
are needed, and you very well may have one of those cases.  Here's a
few things to consider...

1. Is a tree really the right way to represent your data?  Perhaps you
should consider a collection of edges instead.  i.e,

[{:parent node-1 :child node-1}
{:parent node-1 :child node-2}
{:parent node-1 :child node-3}
{:parent node-2 :child node-4}
{:parent node-2 :child node-5}]

Have all you functions interface with this data structure instead.

2. Take a look at assoc-in & update-in.  They are designed to work on
nested maps & vectors, and they play nice with the STM.  Really useful
if you do need a tree.

Hope that helps, interested in what others think.

Sean

On May 4, 10:44 am, Nicolas Oury <nicolas.o...@gmail.com> wrote:
> Dear all,
>
> I have a problem where a lot of concurrency could be gained by having
> a tree of references.
> ie a tree where each nodes contain a ref to a set of similar tree.
>
> (I know that having mutable trees is asking for troubles, but that is
> quite necessary for the things I wish to do.)
>
> I read that
> "The values placed in Refs must be, or be considered, immutable!!
> Otherwise, Clojure can't help you."
>
> I put a lot of hope (and cross fingers) in the "be considered" part of
> the sentence :).
>
> Under which conditions can you use a ref inside a ref?
> What happens if you don't? For cultural purpose: what is the canonical
> example of a problem?
>
> Best regards,
>
> Nicolas.
>
> --
> 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 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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

Reply via email to