ok, like you I would have
-
src/MyPackage.jl, then
module MyPackage
abstract type AbstractA end
include("A.jl")
include("B.jl")
...
export AbstractA, my_func, my_other_func
end
-
src/A.jldoes not need to be another module, just gets included intoMyPackage. SinceAbstractAwas declared beforeA.jlgot included, you can use it:
# src/A.jl
function my_func(a::AbstractA)
# do something
end
- the same goes for
src/B.jl(you don’t need another module):
# src/B.jl
function my_other_func(a::AbstractA)
# do something else
end
If you write include above, the compiler sees MyPackage.jl like one larger source file, but you have the convenience to organise your functionality into several files. Just take care that types like your AbstractA are declared before being used in functions or other type declarations.
I usually have one source file like types.jl and include it first, where I declare common types, used by other source files included after that. Thus I do not need to declare types in my main module file like MyPackage.jl.
Does that make more sense now for you?