The documentation on Modules and the usage of “using” vs “include” is a not crystal clear I think.
I have a main Julia script and three scripts in separate .jl files (in the same directory).
main.jl include("script1.jl") include("script2.jl") include("script3.jl") <some code> end of script
The code executes as I anticipate.
I think if the “include” statement as a proxy for the the code in the “sub-scripts”. I.e. the include(“script1.jl”) represents the code in the sub-scripts line by line in the main script. It is as if the code in the script1.jl is actually in the main.jl script. Is this the right way of thinking of the include statement?
The scope of variables in the main.jl seem to include the ones in the “sub-scripts” when I run main.jl
What is then the difference of using the “using” statement vs the include statements? (I am aware of the necessity to specify the load path for modules in JULIA_LOAD_PATH). Is it same but different? Or same same?
It seems to be same but different, in the sense that in a module you need to use the export statement for variables and functions that you want to be in the main scope. But in the “include” statement all variables and functions are in the main scope by default. Am I right?