Thanks, Stefan. I understand that causing the problem for baz(), but why
does this explain bar()'s failure?
On Tuesday, August 11, 2015 at 1:10:27 PM UTC-7, Stefan Karpinski wrote:
>
> Parametric typing in Julia is invariant, so
>
> !(Vector{Tuple{ASCIIString,ASCIIString}} <: Vector{Tuple{String,String}})
>
>
> even though
>
> Tuple{ASCIIString,ASCIIString} <: Tuple{String,String}.
>
>
> See:
> http://docs.julialang.org/en/release-0.3/manual/types/#parametric-composite-types
>
> On Tue, Aug 11, 2015 at 1:26 PM, Seth <[email protected]
> <javascript:>> wrote:
>
>> Consider
>>
>> foo(a::Vector) = 1
>> bar(a::Vector{Tuple}) = 2
>> baz(a::Vector{Tuple{AbstractString, AbstractString}}) = 3
>>
>>
>> foo(a::AbstractString) = foo([(a,a)])
>> bar(a::AbstractString) = bar([(a,a)])
>> baz(a::AbstractString) = baz([(a,a)])
>>
>> Results:
>>
>> julia> foo("a")
>> 1
>>
>> julia> bar("a")
>> ERROR: MethodError: `bar` has no method matching
>> bar(::Array{Tuple{ASCIIString,ASCIIString},1})
>> in bar at none:1
>>
>> julia> baz("a")
>> ERROR: MethodError: `bar` has no method matching
>> bar(::Array{Tuple{ASCIIString,ASCIIString},1})
>> in baz at none:1
>>
>> I understand why foo() works, but why do bar() or baz() both fail?
>>
>
>