I just developed a Package for Julia https://github.com/Elzair/merchantjl. First I just created one module in the main file and just include()
d all code under it.
Merchant.jl
module Merchant
include("worldinfo.jl")
# ...
export World, seekAllPassengers, # ...
end
@v1.8) pkg> activate .
Activating project at `~/Development/misc/julia/Merchant`
julia> using Merchant: seekAllPassengers, World
julia> seekAllPassengers(2, 2, World("A434934-F"), World("A560565-8"), 2)
Output...
It works, but I would like to split the code into multiple modules, so I created a “modules” branch for that. However, to use World
(defined in module WorldInfo
), I now need to import the main module as well and specify a full path (even though I import and re-export in my main module).
Merchant.jl
module Merchant
include("worldinfo.jl")
include("passenger.jl")
# ...
using .WorldInfo: World
using .Passenger: seekAllPassengers
# ...
export World, seekAllPassengers, # ...
end
worldinfo.jl
module WorldInfo
export World, #...
struct World
# ...
end
end
passenger.jl
module Passenger
include("worldinfo.jl")
using .WorldInfo: World
export seekAllPassengers
function seekAllPassengers(..., source::World, ...)
# ...
end
end
@v1.8) pkg> activate .
Activating project at `~/Development/misc/julia/Merchant`
julia> using Merchant: seekAllPassengers, World
julia> import Merchant
julia> seekAllPassengers(2, 2, Merchant.Passenger.WorldInfo.World("A434934-F"), Merchant.Passenger.WorldInfo.World("A560565-8"), 2)
Output...
The problem is I have three main functions in three different modules, and they all use World
.
julia> seekAllFreight(2, Merchant.Freight.WorldInfo.World("A434934-F"), Merchant.Freight.WorldInfo.World("A560565-8"), 2)
Output
Does anyone know how to fix this?