For example, if I have a function
outer that has an internal implementation
inner, and I want to extend
inner in different modules.
module Outer export outer function outer(a, b) # do something print(methods(inner)) return inner(a, b) end function inner end module A import ..Outer Outer.inner(a, b) = a + b end module B import ..Outer Outer.inner(a, b) = a * b end end
As you can see,
outer is my public API. And I want it to behave differently if I load different modules. Usually, I can define 2 methods on the types of args
b. But in this example,
b have fixed types, so no dispatch on types. The expected behavior is that if I load
outer(1, 2) -> 3, and once I write
using Outer.B in the same REPL environment,
outer(1, 2) -> 2.
julia> using .Outer julia> outer(1, 2) # 1 method for generic function "inner":  inner(a, b) in Main.Outer.B at REPL:252
If I invoke
inner defined in
A is rewritten by that defined in
B. I tried
Base.invokelatest and it gave the same result.