Dispach on parametric types

Is it possible to dispatch on parametric types? Something like that:

function f(x::F{Int}) where F end

Dispatch on types parameterized on ints.

Thank you.

No and it most likely won’t be added since it is believed that this could make the dispatch complex enough to be undecidable.

Also, for this particular case (covariant) it is ambiguous what you want when you have x::T and T <: T1{Int,Int} <: T2 <: T3{Int}. Would you want T1 or T3? or do you want not match?

1 Like

Thank you for the fast reply. It is really a good point, for the example you gave I guess it should be T3, once it is the closest match for the type. Unless someone provides g(x:F{int, int}), where in that case would be T1.

Well, T <: T1{Int} <: T1 {Int, Int}.

The point I’m making is basically that the way type parameters are applied isn’t a fundamental property of the type.

1 Like