Why the global variable is not updated even already initialized and included in all modules?

include doesn’t keep track of logical dependencies between files, it pretty much just copy-pastes a file into the module from which it’s called. When you call include("C.jl") from module B, you’re creating a new submodule Main.B.C that’s completely distinct from Main.C. If this is your first package, I’d recommend starting with everything in one unified module (likely split across multiple files to include from the top level). You can always split things into submodules later on if it makes more sense that way, but starting out with module-heavy code is a recipe for logistical pain points, all the more so when you’re relying on global const musigma (which is, as has been said before, a headache waiting to happen).

That said, if you’re deeply attached to the “one file = one module” style of code organization, you might want to try FromFile.jl.

6 Likes