Everything so far comes together into an object graph. Today you build a small graph where one object is referenced by two parents - a shared node - and walk a path through it, proving the model can express real sharing.
Wire a graph with a shared child and read a value across two hops.
The whole point of reference fields is that objects form a graph, not a tree.
Here s is a shared node: both a and b hold its id in a field, so there are
two distinct paths from the root r down to s. Nothing about the model treats the
second reference specially - s is just an id, and any number of fields may hold it.
Sharing is exactly what makes garbage collection interesting. When you later free
things, you must not reclaim s while either a or b still points at it, and when
you copy the graph you must copy s once and update both references - not copy it
twice. Walking r.field0.field0 and r.field1.field0 and getting the same id 3
both times confirms the graph is wired correctly. With the model complete, the next
chapter answers the central question: starting from the roots, which objects can you
reach?
r, _ := h.New(2); a, _ := h.New(1); b, _ := h.New(1); s, _ := h.New(0)h.SetField(r, 0, a); h.SetField(r, 1, b)h.SetField(a, 0, s); h.SetField(b, 0, s) // s is shared by a and bh.AddRoot(r)// GetField(GetField(r,0),0) == GetField(GetField(r,1),0) == s