On Thu, Sep 17, 2015 at 9:45 AM,  <[email protected]> wrote:
>> function f{T}(sl::Array{T})
>>     .....
>> end
>
>
> Worked like a charm, thank you.
> I don't really get why though, what mechanism prevents Julia to use the
> first version now?

The reason is what Tom said. In julia ParameterizedType{A} is not a
subtype of ParametrizedType{B} even if A <: B (i.e. A is a subtype of
B) (with Tuple as the only exception now) See doc [1] (in particular
the bold note following "the last point is very important").

In your example, you specify f(sl::Array{Any}) to be applicable to sl
of type `Array{Any}`. However, the argument you supply is of type
`Array{state}` which is not a subtype of `Array{Any}` so the method is
not applicable. On the other hand, with `f{T}(sl::Array{T})`, the
method matches when `T == state`.

[1] 
http://julia.readthedocs.org/en/latest/manual/types/#parametric-composite-types

> Does it look at all the available functions called f and see if one is
> better suited, is likely to produce an error of some sort, something else?

Reply via email to