Referencing the same module from multiple files

Welcome to our community! :confetti_ball:

This problem is frequent among novice Julia programmers and was already asked multiple times in this forum. (But I concede that the search utility of Discourse never finds any useful results, even when I know they exist.) See:

Basically, the rule is: include once and import whenever necessary.

Your topmost module should include all files a single time and you should use import/using relative to it (using .MyModule refers to a module defined in the current module, using ..MyModule refers to a module define in the parent module, i.e., a sibling module, and you can do something like using ...MyModule.A.B to go to the parent of the parent and then go down to a specific submodule). In your case, if you include Useful and Create inside Calculate you want to replace the include("useful.jl") inside Create by import ..Useful

10 Likes