Function name conflict: ADL / function merging?

Another option for this particular case:

module A
export foo, AA
struct AA end
foo(::AA) = :A
end

module B
export foo, BB
struct BB end
foo(::BB) = :B
end

module C
import A, B
import A: AA
import B: BB
foo(x::AA) = A.foo(x)
foo(x::BB) = B.foo(x)

@show foo(AA())
@show foo(BB())
end

i.e., just define your own function. You could probably automate this process using a macro and some introspection. But I agree with others that having functions from different packages be automatically ‘merged’ would probably lead to some very confusing behavior.

4 Likes