Not telling anything new, but this way of explaining it helps me understand better:
-
About importing and using modules:
-
using Foo
brings the moduleFoo
and its exported objects into scope. -
import Foo
brings the moduleFoo
into scope, and nothing else.
-
-
About importing and using objects from a module:
-
using Foo: x, y
bringsx
,y
from moduleFoo
into scope, but not the moduleFoo
itself or other objects from it. -
import Foo: x, y
(orimport Foo.x, Foo.y
) does the same, but ifx
ory
are 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
Foo
has been brought into scope of moduleBar
(withusing
orimport
), its functions can be extended in the code ofBar
referring to them asFoo.x
, etc.