Clarification on the scope of import/using/include

Difference import vs using:

  • import MLJModelInterface only brings the module into scope, but none of its exported symbols. You can access all symbols from that module by prefixing them with MLJModelInterface.
  • using MLJModelInterface brings in all exported symbols of that module in the current one. You can still access non-exported symbols from MLJModelInterface as you would when you just would have imported it

import and using act on a Module basis.
If you have a module like

module ABC
include("utils.jl")
end

and

# utils.jl
import MLJModelInterface as MMI 

then MLJModelInterface will be made available also in ABC.
You can think of include(...) as ‘copy-pasting’ the code into the place where the include appeared.

1 Like