How can we make a submodule access a variable defined in its parent module?
Sorry if this is a really basic question, but I’ve spent almost an hour looking for an answer without any success. I have only seen how to access variables from other child modules at the same hierarchical level, or just unrelated modules. Accessing stuff defined in the parent module would seem to be the most natural one of the “inheritances”, so this is a bit counter intuitive to me. I’m thinking it akin to a “closure”, I guess:
module Parent const a = 10 module Child main() = println(a) end end
on the REPL:
julia> Parent.Child.main() ERROR: UndefVarError: a not defined Stacktrace:  main() @ Main.Parent.Child ./REPL:6  top-level scope @ REPL:1
The use case in question:
I’m working on some complex code that reads and writes across different files on many directories. I have defined a TOML configuration file that stores the directories to use. At the moment I can make it work if I always parse the config file inside every child module, but I would rather do it once in the parent module and make it so that everything is neat and organized for the child modules.