Is it possible to have a Julia type for heterogeneous arrays with compile-time-known sizes? In particular I’m thinking of a heterogeneous matrix, so it would be parameterized by number of rows, number of columns and with a type for each of its elements. The latter part is problematic.
I think this is feasible. You can wrap a Tuple like the other StaticArrays do, except your array would be fully parametrized by the Tuple’s type, which contains the types of each element. It’ll be odd because an AbstractArray should have a singular eltype aka T, but maybe all of your arrays could just use Any. And if you subtype StaticArray too, you’ll have to adhere to more type parameter conventions.
Now that I check the Interface docs, the eltype is said to be important, but I’m not familiar with how exactly, except for allocating methods like collect and the default similar. So I don’t know how using Any all the time would pan out. I wondered if the eltype affects the type stability of critical methods like getindex, but it seems like you could just forward it to the wrapped Tupleand it should be inferred , which is technically type-unstable but the compiler does infer the output type given a constant index. setindex! is obviously harder for a wrapped Tuple, but if you intend to implement that, you could look into MArray’s “pointer manipulation”.
For my usecase I don’t think I need setindex!, or iteration, and if I don’t need iteration then eltype shouldn’t matter either, I think. So this is easy, unlike what I thought at first.