I’ve been thinking of it in my head as method where
clauses requiring the parameters be specified because they may be matched across multiple arguments or be accessible values in the method body. Reminds me of this past thread, I’ll just share the last small example sans the thread’s context:
As for this particular case:
# works for _(C), fails for _(C{Int, Float64})
function myfunction(::Type{ A{T1,B{T3}} where {T1,T3} })
return 1
end
# names disambiguated to avoid multimethods
# works for _(C{Int, Float64}), fails for _(C)
function myfunction1(::Type{ A{T1,B{T3}} }) where {T1,T3}
return 1
end
function myfunction2(::Type{ A{T1,B{T3}} } where {T1, T3})
return 1
end
As said before, method parameters must be specified, so myfunction1
failing makes sense. myfunction2
fails because the parametric Type
requires that the T1
and T3
be specified, in the same way that D = Vector{Ref{T}} where T
only includes Vector{Ref{Int}}
or Vector{Ref{Float64}}
, but not Vector{Ref}
.
In fact myfunction1
and myfunction2
would override each other with the same function name because the argument requires specified T1
and T3
, despite not being equivalent (T1
and T3
are not available in the method body nor can they matched across arguments).