See open Issues https://github.com/JuliaLang/julia/issues/2327 and https://github.com/JuliaLang/julia/issues/4345
On Friday, December 12, 2014 8:52:38 AM UTC+10, samoconnor wrote: > > Hi Rob, > > Ok, I see why that "works", but it's a different example. > > Assume that m1 and m2 are libraries from different vendors, they know > nothing about each other, but they both export methods for f(). > > It is surprising to me that importing two modules would cause one to > overwrite methods from the other with no warning or error. > > On Friday, December 12, 2014 9:45:37 AM UTC+11, Rob J Goedman wrote: >> >> Sam, >> >> Maybe below slightly expanded version of your example will help. >> >> I think key is to import m1.f in module m2 >> >> Regards >> Rob J. Goedman >> [email protected] >> >> >> module m1 >> >> export f >> >> f(x::ASCIIString) = println("ASCIIString: " * x) >> f{T<:String}(x::T) = println(" $(typeof(x)): " * x) >> f(x) = println(" $(typeof(x)): " * string(x)) >> end >> >> >> module m2 >> >> import m1.f >> export f >> >> f(x::Int) = println("Int: " * string(x)) >> end >> >> using m1 >> using m2 >> >> f(7) >> f("Foo") >> f("\u2200 x \u2203 y") >> f(12.0) >> f(2.0+3.0im) >> >> >> >> >> On Dec 11, 2014, at 2:18 PM, samoconnor <[email protected]> wrote: >> >> The example below has two modules that define methods of function f for >> different parameter types. >> Both modules are imported. >> It seems like that "using" the second module causes the first one to >> disappear. >> Is that the intended behaviour? >> >> >> !/Applications/Julia-0.3.0-rc4.app/Contents/Resources/julia/bin/julia >> >> module m1 >> >> export f >> >> f(x::String) = println("String: " * x) >> f(x) = println(" ?: " * string(x)) >> end >> >> >> module m2 >> >> export f >> >> f(x::Int) = println(" Int: " * string(x)) >> end >> >> using m1 >> using m2 >> >> f(7) >> f("Foo") >> >> output: >> >> Int: 7 >> ERROR: `f` has no method matching f(::ASCIIString) >> >> >> >>
