A lot of Julia code, including Base
, standard libraries, and packages, includes some helper function to calculate the resulting container type from various inputs, when combined with +
, -
, *
and /
.
Examples are too many to list here, eg LinearAlgebra.lutype
and StaticArrays.arithmetic_closure
are typical.
These calculations use various heuristics, which occasionally lead to bugs (eg this one), especially when various subtypes of <:Real
are considered, eg ForwardDiff.Dual
.
I thought it would be great to arrive at a single, canonical, well-tested implementation that packages could rely on. I wrote up something simple
to get the discussion started. I don’t insist on the implementation being in this package, it is just a way to get it tested in self-contained way.
Comments and suggestions would be appreciated (including bikeshedding names, but ideally conceptual issues. but yes, also bikeshedding names ).