Proposal: Adding Optional Static Interface/Traits Checking to Julia

This is seemingly parenthetical to the original discussion (sorry for derailing it somewhat), but I feel that the term “multiple dispatch” is often misused. This may be my misunderstanding, and I am happy to be corrected.

Multiple dispatch in julia means that methods are specialized for multiple argument types. If only one argument is involved in a call, this is no different from single dispatch, and f(x) in Julia is equivalent to x.f() in python. What makes julia differ from python’s dispatch is when we have f(x, y), which is different from python’s x.f(y), as python usually can’t specialize on y automatically, whereas julia does specialize on both the argument types.

The example presented above:

module MultipleDispatch
function foo(x::Int32)::Int32
    return x + 2
end

function foo(x::Int64)::Int64
    return x + 3
end

function foo(x::Float64)::Float64
    return x + 4
end
end

has different methods associated with each type, but this is still using single-dispatch on the only argument. From what I understand, the duck-typing example is where a generic method is provided to define the behavior for an abstract type, and julia automatically compiles specialized method instances for specific concrete types. If I understand correctly, multiple dispatch is an extension of this to have method instances specialize on more than one argument.

Perhaps the term is being used differently than what I might be familiar with, so it might help if this is clarified.

In any case, this isn’t the topic of discussion, and I agree that interfaces and static checking will be a great step. Looks like the devs are already thinking about this.

1 Like