I have a problem with modules.
I have a file with
using .Branch, .OtherBranch, .Stalk
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
but it fails to compile, saying that StalkDef is not defined.
I tried also with
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.
Yes, that’s right.
That’s the actual problem–you can’t do this. Here’s a simpler non-working example:
julia> module A
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.
Oh, thank you! I am trying to refactor the code to avoid this…
@rdeits, I pilfered your nice MWE for
It is maybe worth noting that while you may not do this with two “sibling modules” you can do it with “parent and children”:
julia> module Outer
Which compiles and gives a
ERROR: StackOverflowError: if any of the functions is called.