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)
> 
> 

Reply via email to