On Friday, May 30, 2014 11:32:39 AM UTC-4, Tim Holy wrote:
>
> It comes down to the challenge in writing these lines:
> https://github.com/JuliaLang/julia/blob/master/base/array.jl#L751-L768
> in type-stable way that works for empty arrays as well as ones that have
> elements. Unfortunately this is not a new issue, so I didn't file one. Nor
> do I
> see a simple solution, or I would just fix it.
>
I don't think it has anything to do with empty arrays per se, and I do
think there may be a straightforward fix in this particular case.
The problem is that promote_array_type(typeof(Meter),Float64) is
necessarily an abstract SIQuantity type: the SIUnits package does not know
how to do the type promotion because it doesn't know what operation you are
performing on the Meter quantity.
A fix could be to replace the promote_array_type with something like
typeof(($f)(one(A), one(T)))
and then the Array should get the correct type for multiplication by
SIQuantities like 1Meter. Multiplying by an SIUnit object like Meter will
require https://github.com/loladiro/SIUnits.jl/issues/18 to be fixed.