Not telling anything new, but this way of explaining it helps me understand better:
-
About importing and using modules:
-
using Foobrings the moduleFooand its exported objects into scope. -
import Foobrings the moduleFoointo scope, and nothing else.
-
-
About importing and using objects from a module:
-
using Foo: x, ybringsx,yfrom moduleFoointo scope, but not the moduleFooitself or other objects from it. -
import Foo: x, y(orimport Foo.x, Foo.y) does the same, but ifxoryare functions, they’ll be available for method extension in the current scope.
-
-
Additionally, all functions from a given module are always available for method extension in their module’s scope. So, if the module
Foohas been brought into scope of moduleBar(withusingorimport), its functions can be extended in the code ofBarreferring to them asFoo.x, etc.