Closed SebastianM-C closed 4 years ago
That's not a bad idea!
Be careful to consider cases like Polar(1.0, 1)
which probably should use promote
or some such (if both inputs are Number
, say).
I'm not sure how to handle
Base.eltype(::Polar{T}) where {T} = T
Base.eltype(::Type{Polar{T}}) where {T} = T
when extending to two type parameters.
Should it use promote_type(T,A)
?
I considered
Base.eltype(::Polar{T,A}) where {T,A} = promote_type(T, A)
Base.eltype(::Type{Polar{T,A}}) where {T,A} = promote_type(T, A)
in #60, but I'm not sure it makes sense.
I think eltype
cannot make a lot of sense in the unitful case. Sure it can promote to Any
in principle, but that's not useful for the way it seems to be used internally.
It seems a bit of a weird API to be extending anyway - maybe we should consider removing it?
Agreed; it neither iterates nor supports in
therefore eltype
is a pun and should be removed.
The structures for the coordinate types, like
Polar
implicitly assume that the type for angles is the same as the type for the radius.https://github.com/JuliaGeometry/CoordinateTransformations.jl/blob/383c023d90e71ee89e6f3728971a9fed3dcbc0a0/src/coordinatesystems.jl#L7-L10
If an additional type parameter would be added, I think it could make CoordinateTransformations.jl and Unitful.jl compatible,
If you are interested, I can try this in a PR.