I am trying to update some of my code to make it work with Julia v0.7.0-beta2.0.
I am a bit confused about what is the right way to include a bunch of modules that refer to each other.
Assume I have three files that each contain a module:
1. Module: Types.jl
(a module that holds struct definitions)
module Types export TwoNumbers mutable struct TwoNumbers a::Int64 b::Int64 end end
2. Module: Operations.jl
(a module that contains certain functions that work on the custom structs defined in Module 1)
module Operations using Types export switchNumbers! function switchNumbers!(tn::Types.TwoNumbers) a = copy(tn.a) b = copy(tn.b) tn.a = b tn.b = a return nothing end end
3. Module MainModule.jl
( a parent module that uses the operations from module 2)
include("./Types.jl") include("./Operations.jl") module MainModule using Operations, Types export performOperation function performOperation() tn = TwoNumbers(1,2) println("Original object: a=$(tn.a), b=$(tn.b)") switchNumbers!(tn) println("After switching: a=$(tn.a), b=$(tn.b)") end end
Output of the following commands in Julia 0.6.0:
include("MainModule.jl") MainModule.performOperations() >>>Original object: a=1, b=2 >>>After switching: a=2, b=1
However, with Julia v0.7.0-beta2.0, I get:
ERROR: LoadError: LoadError: ArgumentError: Package Types not found in current path: - Run `Pkg.add("Types")` to install the Types package. Stacktrace:  require(::Module, ::Symbol) at ./loading.jl:816  include at ./boot.jl:317 [inlined]  include_relative(::Module, ::String) at ./loading.jl:1034  include(::Module, ::String) at ./sysimg.jl:29  include(::String) at ./client.jl:393  top-level scope at none:0  include at ./boot.jl:317 [inlined]  include_relative(::Module, ::String) at ./loading.jl:1034  include(::Module, ::String) at ./sysimg.jl:29  include(::String) at ./client.jl:393  top-level scope at none:0 in expression starting at /<PATH>/TestModules/Operations.jl:2 in expression starting at /<PATH>/TestModules/MainModule.jl:2
My question is: What is the best practice to include several files with modules and interdependencies into a parent module MainModule.jl (in Julia 0.7)?