I read about include, use and import in Julia.
It seems they can all be used to ‘import’ a module.
But I am still not very clear the difference between include, use and import.
if I have a module called Mymod, and I want to use it in the main program,
is
include(“Mymod.jl”) enough?
Or do I have to do,
include(“Mymod.jl”)
use .Mymod
Also, could anyone please explain a little bit more,
so, when to use ‘use’, and when to use ‘import’?
What have you read? What exactly are you unclear about?
include is used for including the content of a file into your current program. It has per se nothing to do with modules or namespaces. using and import on the other hand have nothing to do with files, and deal exclusively with modules/namespaces.
Yes, that’s the difference between using and import - the former brings all exported names into scope, while the latter only brings NiceStuff (the module identifier) into scope.