Dependencies of src files inside a package

The problem is that you’re include()ing the same file multiple times. Each time you include("a.jl"), you create a new module named A, with new, incompatible, types and functions. You need to ensure that each file is included exactly once.

For example, you could do:

## M.jl
module M

include("A.jl")
using .A
include("B.jl")
using .B

end

## A.jl
module A
  ...
end


## B.jl
module B

using ..A

end

Note that we can still use module A within module B without including it again there.

6 Likes