How does Julia dispatch on concrete methods?

It doesn’t work because ModA.length and ModB.length are two different functions and ModA.foo calls ModA.length. To extend ModA.length in ModB instead of creating a new function ModB.length, you need to qualify it or import it explicitly, i.e., either

import ..ModA

function ModA.length(x::Bar)
    return 42
end

or

import ..ModA: length

function length(x::Bar)
    return 42
end

Edit: The table in this section of the manual shows what is brought into scope and what functions are made available to extend by using/import.

6 Likes