# Struct cross dependency

**URL:** https://discourse.julialang.org/t/struct-cross-dependency/51680
**Category:** General Usage
**Created:** [December 11, 2020, 7:02pm UTC](https://discourse.julialang.org/t/struct-cross-dependency/51680 "2020-12-11T19:02:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Ronneesley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronneesley/32/11072_2.png) [@Ronneesley](https://discourse.julialang.org/u/Ronneesley)
#### Post date: [December 11, 2020, 7:02pm UTC](https://discourse.julialang.org/t/struct-cross-dependency/51680/1 "2020-12-11T19:02:37Z")

</div>

Hello,

There is something new about struct cross dependency?

```julia
mutable struct Father
    child::Child
end

mutable struct Child
    father::Father
end

```

---

<div class="post-metadata">

### Author: ![FedericoStra](https://avatars.discourse-cdn.com/v4/letter/f/76d3ee/32.png) [@FedericoStra](https://discourse.julialang.org/u/FedericoStra)
#### Post date: [December 11, 2020, 7:20pm UTC](https://discourse.julialang.org/t/struct-cross-dependency/51680/2 "2020-12-11T19:20:57Z")

</div>

Why not this?

```julia
abstract type AbstractChild end

mutable struct Parent{C<:AbstractChild}
    child::C
end

mutable struct Child <: AbstractChild
    parent::Parent{Child}
    Child() = new()
end

```

Then you can do

```julia
c = Child(); p = Parent(c); c.parent = p; # create them

c.parent === p && p.child === c # true

(c, p) # do something with them

```

---

<div class="post-metadata">

### Author: ![Ronneesley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronneesley/32/11072_2.png) [@Ronneesley](https://discourse.julialang.org/u/Ronneesley)
#### Post date: [December 11, 2020, 8:22pm UTC](https://discourse.julialang.org/t/struct-cross-dependency/51680/3 "2020-12-11T20:22:41Z")

</div>

Hi @FedericoStra,

I didn’t know this feature: incomplete initialization.

I will study it to be able to see if it solves my real problem.

Thank you.
