Array seems like a strange return type for this interaction:
julia> map(+, (1, 2), (x=1, y=2))
2-element Array{Int64,1}:
2
4
Why not tuple?
Array seems like a strange return type for this interaction:
julia> map(+, (1, 2), (x=1, y=2))
2-element Array{Int64,1}:
2
4
Why not tuple?
Because it falls back to the general iterable collection method.
A special method for this could be added, but it may be considered breaking. I think that for mixed arguments, map falling back to collect is fine.
A workaround is
julia> map(+, (1, 2), values((x=1, y=2)))
(2, 4)
I was figuring that was the reason, and changing it now would be breaking. But it just seems like
it should return some kind of tuple - that’s the least surprising option. The workaround is easy, just debugging the issue the first time it happens is weird.
I am not sure — one could argue for a NamedTuple.
I think it is best if map tries to preserve type and structure for homogeneous arguments, and falls back to an Array for heterogeneous ones. This is easy to reason about.
But array allocates and isn’t type stable
Maybe file an issue so that we track it for Julia 2.0.