After lots of searching and reading, I think now I have a better understanding on how Julia code should be organized in modules to make it reusable.
I have to say that the “Modules” section of the official Julia documentation (which I had already read before starting this thread) did not help me very much on this, while I found more useful the “Modules and packages” section of the “Introducing Julia” Wikibook.
What however finally opened my eyes are the following two GitHub threads (I add the links here thinking they may be useful for others in future hitting this discussion):
https://github.com/JuliaLang/julia/issues/4600
https://github.com/JuliaLang/julia/issues/23619
IMHO the Julia documentation should eventually include more insight and examples on this topic, but I understand that some important details are still under discussion, so I guess we should wait for them to be completely defined and implemented.
Now I feel I am starting to think more Julia than Python, so if you agree in order to make the julia-config.jl
functions reusable in juliac.jl
I am going to submit a PR with the following edits:
- Take all reusable functions out from the
julia-config.jl
script, and put them in aJuliaConfig.jl
script. - In the
JuliaConfig.jl
script, wrap all the code within a module namedJuliaConfig
, and export all reusable functions (cflags
,ldflags
,ldlibs
,allflags
). - In the
julia-config.jl
script add the following lines:
include("JuliaConfig.jl")
using .JuliaConfig
- Similarly, in the
juliac.jl
script add the following lines:
include(joinpath("path_to_JuliaConfig", "JuliaConfig.jl"))
using .JuliaConfig
If I understood correctly, this is the current syntax as of Julia v0.6 (please let me know otherwise).
In future, from the two GitHub threads linked above maybe the include
statement will not be needed anymore, however in this case it is not clear to me how I would set the "path_to_JuliaConfig"
. I am going to ask this question there.