module Root
include("Branch.jl")
include("OtherBranch.jl")
include("Stalk.jl")
using .Branch, .OtherBranch, .Stalk
end
Now, in OtherBranch.jl I need something which is defined in Stalk, where I have defined a module called StalkDef, so my code is as follows
module OtherBranchDef
using ..StalkDef
end
but it fails to compile, saying that StalkDef is not defined.
I tried also with
module OtherBranchDef
using Root.StalkDef
end
but it is not working.
It seems like it is processing the file from top to bottom, so I would have to move the inclusion of the two files (I cannot, they “use” each other).
How does this work, I think I’m missing something.
That’s the actual problem–you can’t do this. Here’s a simpler non-working example:
julia> module A
module B
using ..C
end
module C
using ..B
end
end
ERROR: UndefVarError: C not defined
There must be a non-cyclic ordering of your various modules; they cannot depend on each other. If they both need to share some common information (such as a type definition), then you can move the shared information into a new module and have both modules depend on that shared module.