Hi,

I want to define a record that represents a tree items. The idea is each 
item is a component that can have parent and children. The parent and the 
children are components too,

So, I define this record by:
(defrecord Component [name children parent])

After, I declare 2 components:
(def parent (Component. "Parent" (atom {}) (atom nil)))
(def child (Component. "Child" (atom {}) (atom nil)))

To link the parent with the child, I do:
(swap! (:children parent) assoc :a child)
(reset! (:parent child) parent)

And bang, the second call raises an exception: StackOverflowError   
java.util.regex.Pattern$BmpCharProperty.match (Pattern.java:3715)

If I reverse the code:
(reset! (:parent child) parent)
(swap! (:children parent) assoc :a child)

The reset! call passes fine but the swap! one fails with the same exception.

Where does this issue come from?

Thanks.

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