Hi,
I want to be able to call out from a function (defined within a module) to
a method with a specific name but that is defined outside the module. Let
me try to show the actual code to help clarify:
module M
abstract G
s_type(g::G) = g.s_type
function new_s(g::G)
s = s_type(g)
s(g)
end
# This is the function that should call out to methods named start
# that are defined outside this module:
function g(g::G)
s = new_s(g)
println("start(", typeof(g), ", ", typeof(s), ")")
start(g, s)
end
abstract S
type DefaultS <: S
g
DefaultS(g::G) = new(g)
end
end
type G2 <: M.G
s_type
function G2()
new(M.DefaultS)
end
end
# This is the function I want to call out to from within the module M:
function start(g::G2, s::M.DefaultS)
1
end
g2 = G2()
s = M.DefaultS(g2)
Now if I call start directly it does as expected:
julia> start(g2, s)
1
But if I call through the g function in the module it complains:
ulia> M.g(g2)
start(G2, DefaultS)
ERROR: no method start(G2, DefaultS)
in g at none:15
despite:
julia> methods(start)
# 1 method for generic function "start":
start(g::G2,s::DefaultS) at none:2
What have I missed? Thanks for any help,
Robert Feldt