I was wondering whether in principle one could mostly get rid of method ambiguities by adding simple rules like “in case of ambiguity, the method with the most specific first argument wins (if the first argument is equal the second argument is compared, etc…)”.
I’ve found the current behavior annoying when(for example) trying to overload
reshape for StructArrays. I would like to simply forward the
reshape operation to the various field arrays of the
StructArray but (after loading OffsetArrays) there are 9 methods for
reshape(v::AbstractArray, args...), some of which with rather tricky signatures, and one would need to overload all the signatures to avoid ambiguities. If a tighter first argument implies the method gets chosen, I could simply do:
Base.reshape(v::StructArray, args...) = ...
A side benefit would be (at least intuitively) that selecting the appropriate method to call would become a much easier problem, not sure whether this could help with latency issues or is unrelated.
Is the concern that selecting between two ambiguous method based on first argument could actually surprise users and they would prefer a clear error message?