Hello.
I’m currently using Julia for the first time in a project of more than one file and I’m struggling with module
, using
and include
.
For this example, let say that I have a few files :
big.jl
small1.jl
small2.jl
small3.jl
In small3.jl
I have some functions that I would like to use in the 3 others files. In big.jl
I would like use some functions from the 3 small files. Also, in big.jl
I created a module :
module Big
include("small1.jl")
include("small2.jl")
include("small3.jl")
... other stuff
end
Since we are collaborating on that project, we found it important to be able to read and understand easily the codes. So, we would like to be able to know where each functions are defined.
For example, in small1.jl
and small2.jl
I would like to be able to call functions from small3.jl
as small3.foo(...)
or something similar.
We can do that by putting everything in small3.jl
into a module. But, then if I included small3.jl
in small1.jl
, small2.jl
and big.jl
I got some warning telling me that the module in small3.jl
have been included more than once when I included big.jl
.
The other way that we found is to only include small3.jl
in big.jl
and not in the two others files. Since both small1.jl
and small2.jl
are included in big.jl
we can call big.small3.foo(...)
in those file. But, it’s not exactly what I wanted first. The other problem is that if I create a new module that used big
than it looks like I need to call the function like this other.big.small3.foo(...)
in small1.jl
and small2.jl
.
Finally, my question is : What is the Julia way to do that kind of thing?
Thanks!