You are not using submodules here, you are just creating two individual “packages”, though because you are pushing to LOAD_PATH
these things are less clear.
A submodule must be defined within the scope of a parent module, like in the example here copied below, or by includ
ing the file containing the submodule within the parent module. The module blocks must be nested.
module Parent
module Utils
...
end
using .Utils
...
end
If you want to do that precompilation test properly with submodules, you would need the following:
module MyModule # MyModule.jl
include("MySubModule.jl")
using .MySubModule # note the dot
export f
f(a) = 2*g(a)
end
As a side note, pushing to the LOAD_PATH
is not the best way of organizing code, since you won’t be making use of dependency resolution and reproducible environments you can do with a Project.toml
file and using Pkg
.