What you are looking for is described
in
http://julia.readthedocs.org/en/latest/manual/modules/#relative-and-absolute-module-paths
in P.jl you include all your submodules
module P
include("u.jl")
include("a.jl")
include("b.jl")
using .A, .B
export f, g
end
u.jl
module U
g() = 5
f() = 6
end
a.jl and b.jl both lokk like this
module A
import ..U
f = U.f
g = U.g
export f, g
end
so one dot as a prefix looks in the namespace of the current module and two
dots as prefix looks in the namespace of the parent module.
Hope that helps
On Sunday, 24 August 2014 14:10:58 UTC+2, Andrei Zh wrote:
>
> Let's say I have following project layout:
>
> P.jl that contains module P -- main package module, exposes code from a.jl
> and b.jl
> a.jl that contains module A and
> b.jl that contains module B -- some domain specific modules
> u.jl that contains module U -- util functions
>
> Now I want to use functions in U from modules A and B. In simplest case I
> would just include("u.jl") inside of a.jl and b.jl, but this way functions
> from U will be defined in both - A and B. So I really want to import U, not
> include u.jl, but I can't do this since u.jl is not on the LOAD_PATH (and
> messing with it manually looks somewhat bad to me).
>
> Is there some standard way to tackle it?
>
> (Note, that A, B and U are here just for code splitting, other ways to do
> same stuff are ok too.)
>