Question: What is the difference between using
and import
in Julia when I'm building my own module?
My guess based on reading the docs: using
is used to bring another module into the name-space of the current module. import
is used to bring specific types/functions/variables from other modules into the name-space of the current module.
So, how wrong am I?
The Julia Modules documentation states:
The
import
keyword [...] only operates on a single name at a time. It does not add modules to be searched the wayusing
does.import
also differs fromusing
in that functions must be imported usingimport
to be extended with new methods. [...] Functions whose names are only visible viausing
cannot be extended.
(Emphasis mine.)
For example, you can use import
to add methods to Base.show
to pretty-print your own types, but not with using
.
There is also importall
that imports all exported names of a module.
(This answer refers to Julia 0.6; the documentation was reworded for 1.0.)