--
--
--
I'm not following your example 100% but parametric types are invariant in Julia, which means that SortDict{Int,Int} is not a subtype of SortDict{Any,Any}, for example. In general, Foo{A} and Foo{B} are only disjoint unless A and B are the same.
--
julia> sd = SortDict()
SortDict(Nil(),isless)
julia> sd["foo"] = 1/3
no method assign(SortDict{Any,Any},Float64,ASCIIString) # BAD!
in method_missing at base.jl:70
function assign{K, V, K1<:K, V1<:V}(sd :: SortDict{K, V}, value :: V1, key :: K1)h, c, sd.tree = assign(sd.tree, key, value, sd.cf)end
julia> foo(x,y) = falsejulia> foo{S,T<:S}(x::S,y::T) = trueS not defined
--
function assign{K, V}(sd :: SortDict{K, V}, value :: V, key :: K)
h, c, sd.tree = assign(sd.tree, key, value, sd.cf)end
--
function assign{K,V}(h::Dict{K,V}, v, key)
julia> d = Dict{Int,Int}()Dict()julia> d[1.0] = 2.02.0
julia> d{1=>2}
julia> d[1.5] = 2InexactError()in assign at dict.jl:304julia> d[1.0] = 2.5InexactError()in assign at dict.jl:304
--
Dispatch like that doesn't work:julia> foo(x,y) = falsejulia> foo{S,T<:S}(x::S,y::T) = trueS not definedThe RHS of a type bound on a type parameter for a method can't itself be a parameter. That would allow stronger dispatch than just diagonal dispatch.