It’s not directly possible, since there’s no way for the compiler to know the type of each element if you’re just iterating through them in a loop. But there are a lot of other options to make this work:
- Unrolled.jl
- ArrayPartition
- TypeSortedCollections.jl
- Lisp-y tuple recursion like in Type stability when arguments are functions - #4 by tim.holy
(this isn’t specific to having a wrapper around a tuple–you’ll have the same issues with regular Julia tuples too). All of these make it possible to call a function on a mixture of types in an inferable way, without necessarily implementing a type-stable getindex().
Another option would be to store FunctionWrappers instead of the objects themselves in order to create a concretely-typed collection.