# Module import vs using

**URL:** <https://discourse.julialang.org/t/module-import-vs-using/48707>\
**Category:** New to Julia\
**Tags:** question, module\
**Created:** [October 20, 2020, 8:55pm UTC](https://discourse.julialang.org/t/module-import-vs-using/48707 "2020-10-20T20:55:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkarikom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkarikom/32/7096_2.png) [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Post date:** [October 20, 2020, 8:55pm UTC](https://discourse.julialang.org/t/module-import-vs-using/48707/1 "2020-10-20T20:55:58Z")

</div>

I’m confused by [this table](https://docs.julialang.org/en/v1/manual/modules/#Summary-of-module-usage) in the docs. The last column is identical for rows 1,3 (`import MyModule` and `using MyModule`), which seems inconsistent with the previous paragraph:

> `import` also differs from `using` in that functions imported using `import` can be extended with new methods.

---

<div class="post-metadata">

**Author:** ![Vasily\_Pisarev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vasily_pisarev/32/7929_2.png) [@Vasily\_Pisarev](https://discourse.julialang.org/u/Vasily_Pisarev)\
**Post date:** [October 20, 2020, 9:13pm UTC](https://discourse.julialang.org/t/module-import-vs-using/48707/2 "2020-10-20T21:13:29Z")

</div>

The last statement means that functions imported via `import` are available for extension without the additional module qualifier, i.e. it refers to the last column of rows 2, 4 and 5.

---

<div class="post-metadata">

**Author:** ![mkarikom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkarikom/32/7096_2.png) [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Post date:** [October 20, 2020, 9:32pm UTC](https://discourse.julialang.org/t/module-import-vs-using/48707/3 "2020-10-20T21:32:38Z")

</div>

Thanks @Vasily_Pisarev, I’m just wondering why is column 3 the same for rows 1 and 3, sorry if that wasnt clear

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [October 20, 2020, 9:33pm UTC](https://discourse.julialang.org/t/module-import-vs-using/48707/4 "2020-10-20T21:33:00Z")

</div>

This was also recently discussed:

> [@Why does code in a package use "using" and "import"?](https://discourse.julialang.org/t/why-does-code-in-a-package-use-using-and-import/48500):
>
> Hi, In looking at how Julia packages are implemented, I see a common idiom that I don’t quite understand. For example, if you look at YaoBase/src/YaoBase.jl at [https://github.com/QuantumBFS/YaoBase.jl/blob/master/src/YaoBase.jl](https://github.com/QuantumBFS/YaoBase.jl/blob/master/src/YaoBase.jl) you see using YaoAPI import YaoAPI: isunitary, isreflexive, iscommute, AbstractRegister, AdjointRegister, AbstractBlock, PostProcess, NotImplementedError, LocationConflictError, QubitMismatchError, instruct!, focus!, relax!, nqubits, nremain, nactive, nb…

---

<div class="post-metadata">

**Author:** ![Vasily\_Pisarev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vasily_pisarev/32/7929_2.png) [@Vasily\_Pisarev](https://discourse.julialang.org/u/Vasily_Pisarev)\
**Post date:** [October 21, 2020, 8:18am UTC](https://discourse.julialang.org/t/module-import-vs-using/48707/5 "2020-10-21T08:18:06Z")

</div>

> [@heliosdrm](#):
>
> This was also recently discussed:

Aha, so what I was trying to say was

> 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 module `Bar` (with `using` or `import` ), its functions can be extended in the code of `Bar` referring to them as `Foo.x` , etc.

While the cited paragraph from the docs refers to another case, corresponding to table’s rows 2, 4 and 5.

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [October 21, 2020, 9:30am UTC](https://discourse.julialang.org/t/module-import-vs-using/48707/6 "2020-10-21T09:30:38Z")

</div>

Yes, the nuance is that the paragraph of the docs says:

> functions imported using `import`

And this happens only in rows 4 and 5 (to be compared with row 2, where you are _using_ functions). In rows 1 and 3 you are not importing/using _functions_, but the module that contains them.
