Why are tuples covariant?

The manual section on Parametric Types says that

Julia’s type parameters are invariant

but the section on Tuple Types says

Tuple types are covariant in their parameters

I’m just curious about the reason behind this design choice. It seems a bit confusing to me as a Julia novice, but I’m sure somebody much more knowledgeable than I had a good reason to design it this way.

Thanks,
Oliver

The reason here is mainly historical. There actually is a proposal to change it for Julia 2.0 https://github.com/JuliaLang/julia/issues/24614

8 Likes

Also dispatching on Tuples is useful and it’s easier with covariance, especially Vararg.

1 Like