Nice. However,
julia> f=BigForest(Elephant(1.0), Elephant(2.0), ""); f.elephant2.hunger
2.0
julia> typeof(f.elephant2)
ElephantView{:elephant2, BigForest}
julia> typeof(f.elephant2) == typeof(f.elephant1)
false
which brings up what I noted upthread:
I think this would really require new (albeit simple) core intrinsics relating to GC write barriers and a very_unsafe_pointer_to_objref(typ::DataType, p::Ptr) = unsafe_pointer_to_objref(p)::typ
that assumes the type instead of checking (so UB instead of exception if it’s wrong, unless check-bounds=yes
, or some compiler flag for the julia runtime is set).