On Wed, Oct 12, 2016 at 1:22 PM, esproff <espr...@gmail.com> wrote:
> Consider the code:
>
> abstract AbstractFoo
>
> type Foo <: AbstractFoo
> end
>
> f(x::AbstractFoo, y::Integer) = "method 1"
> f(x::Foo, y::Real) = "method 2"
>
> foo = Foo()
> f(foo, 1)
>
> This code results in an ambiguity error, since both methods contain one
> argument with a more specific type declaration than the other. Now
> consider this code:
>
> abstract AbstractFoo
>
> type Foo <: AbstractFoo
> end
>
> f(x::AbstractFoo, y::Integer) = "method 1"
> f{T<:Real}(x::Foo, y::T) = "method 2"
>
> foo = Foo()
> f(foo, 1)
>
> This code, in my opinion, should work, since the second method spawns a
> bunch of sub-methods, one for each concrete subtype of Real in the second
> argument, and thus one of these sub-methods should be
>

## Advertising

No the set of signature the second method matches in the second case is the
same as that in the first case.
>
> f(x::Foo, y::Int) = "method 2"
>
> which then eliminates the ambiguity, but it doesn't behave this way, why
> is that?
>