How to deal with recursive type dependencies in immutable structs?

Having a non-concrete field in a struct is indeed bad for performance. However, you could do

abstract type SuperFoo end
struct Bar{T <: SuperFoo}
    b::T
end

struct Foo <: SuperFoo
    b::Bar
end
2 Likes