Is it possible to preserve the fields and methods of a type when creating a subtype?

You can overload getproperty and setproperty!:

mutable struct SubDataFrame
    Roll
    Pitch
    Yaw
end

struct Plane
    flight :: SubDataFrame
end

A = SubDataFrame(1,2,3)
B = Plane(A)

get_flight(B :: Plane) = getfield(B, :flight);
Base.getproperty(B :: Plane, n :: Symbol) = getproperty(get_flight(B), n)
Base.setproperty!(B :: Plane, n :: Symbol, x) = setproperty!(get_flight(B), n, x)

A.Roll === B.Roll #true
A.Roll = 17
B.Roll  # 17
1 Like