I'm trying to build a simply binary tree (made of node structs which each have two "child" slots and one "parent" slot)
(defstruct node child-a child-b parent)
I can for example create two new nodes like so:
(defparameter a (make-node))
(defparameter b (make-node))
Now I want to create their parent like so:
(defparameter c (make-node :child-a a :child-b b))
Fine, good so far.
Now I need to let the children nodes (a and b) link back to their parent c. (so the binary tree can be traversed in 2 directions)
HOWEVER I get an immediate error when trying to set the parent value for a and b:
(setf (node-parent a) c)
*** - Program stack overflow. RESET
Does CL not allow structs pointing to each other?
(defstruct node child-a child-b parent)
I can for example create two new nodes like so:
(defparameter a (make-node))
(defparameter b (make-node))
Now I want to create their parent like so:
(defparameter c (make-node :child-a a :child-b b))
Fine, good so far.
Now I need to let the children nodes (a and b) link back to their parent c. (so the binary tree can be traversed in 2 directions)
HOWEVER I get an immediate error when trying to set the parent value for a and b:
(setf (node-parent a) c)
*** - Program stack overflow. RESET
Does CL not allow structs pointing to each other?