Union all Types


Would be a nice short-hand for

Pair{Symbol,T} where T<:Number

is there a reason it can’t be written like this?
it would be nice to write

f(x::Pair{Symbol,Number}) = 1

instead of

f(x::Pair{Symbol,T}) where T<:Number = 1

One can’t be a shorthand for the other because they mean different things. It comes down to the same thing that’s explained here: Types · The Julia Language where Point{Real} is not the same as Point{T} where {T <: Real} because a Point{Int} is not a subtype of Point{Real}. LIkewise a Pair{Symbol, Float64} is not a subtype of Point{Symbol, Number}; they’re actually distinct types.


Thanks. That link gives a shorthand:

f(x::Pair{Symbol,<:Number}) = 1