# Confused about intent of using/import (docs)

**URL:** <https://discourse.julialang.org/t/confused-about-intent-of-using-import-docs/53834>\
**Category:** General Usage\
**Tags:** module\
**Created:** [January 23, 2021, 4:30pm UTC](https://discourse.julialang.org/t/confused-about-intent-of-using-import-docs/53834 "2021-01-23T16:30:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MA\_Laforge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ma_laforge/32/385_2.png) [@MA\_Laforge](https://discourse.julialang.org/u/MA_Laforge)\
**Post date:** [January 23, 2021, 4:30pm UTC](https://discourse.julialang.org/t/confused-about-intent-of-using-import-docs/53834/1 "2021-01-23T16:30:44Z")

</div>

I was reading the (new v1.7) docs on modules (Standalone `using` and `import`):

> **[Standalone using and import - Modules · The Julia Language](https://docs.julialang.org/en/v1.7-dev/manual/modules/#Standalone-using-and-import)**
>
> Documentation for The Julia Language.

Specifically:

> Possibly the most common way of loading a module is `using ModuleName`. This loads the code associated with `ModuleName`, and brings
> 
> 1. the module name
> 2. and the elements of the export list into the surrounding global namespace.

I understand the two points, but I find the first two sentences confusing. I’m guessing they are probably incorrect.

### Confusion

Is the above statement this really the intent? I ask because I know there is talk of changes to allow `using` and `import` to recognize files in the source tree:  
 → [relative using/import should search current directory · Issue #4600 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/4600)

AFAIK, the current solution allows the use of `using` and `import` to load _ **packages** _ (not modules).

At the moment, I thought non-package modules were _ **already** _ loaded (otherwise, Julia wouldn’t recognize the symbol), and so:

- `import moda` basically does nothing (symbol already available),
- `import moda.submodule` makes `submodule` symbol directly available, and
- `using moda` makes all exported symbols from `moda` available in current scope.

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [January 25, 2021, 1:24pm UTC](https://discourse.julialang.org/t/confused-about-intent-of-using-import-docs/53834/2 "2021-01-25T13:24:45Z")

</div>

I am not entirely sure what is your point. `using` may be used to load modules that are not packages. Example:

```julia

module Outer
    module Inner
        f(a) = 2*a
        export f
    end
    using .Inner
    g(a) = f(a) * 2
    export g
end

```

---

<div class="post-metadata">

**Author:** ![MA\_Laforge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ma_laforge/32/385_2.png) [@MA\_Laforge](https://discourse.julialang.org/u/MA_Laforge)\
**Post date:** [January 25, 2021, 3:19pm UTC](https://discourse.julialang.org/t/confused-about-intent-of-using-import-docs/53834/3 "2021-01-25T15:19:43Z")

</div>

@Henrique_Becker: My issue is a question of using _ **precise** _ (correct) words to avoid confusing the reader.

The `using .Inner` statement you use here does not actually _ **load** _ `module Inner`. That module was loaded when the Julia interpreter read through your code.

The only thing that the `using .Inner` statement does in your case is “import” symbols that `module Inner` “export”-ed. That’s the 3rd point I made in my first entry:

> [@MA\_Laforge](#):
>
> - `using moda` makes all exported symbols from `moda` available in current scope.

### Why so pedantic?

I think it is imperative to use precise words for this document on modules & packages, because many of these concepts can be somewhat tricky and (possibly) unique to Julia. I have recently been reading several questions from new (and sometimes seasoned) Julia users who appear to have a confused mental model of the module/package system.

So my question is mostly to understand if I should make a PR to correct this statement, or find out if I am truly mistaken in my own understanding of the `using` & `import` statements.

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [January 25, 2021, 4:39pm UTC](https://discourse.julialang.org/t/confused-about-intent-of-using-import-docs/53834/4 "2021-01-25T16:39:24Z")

</div>

> [@MA\_Laforge](#):
>
> I think it is imperative to use precise words for this document on modules & packages, because many of these concepts can be somewhat tricky and (possibly) unique to Julia.

I want to applaud this goal of language precision. Equivalents (or not) of modules, packages, namespaces, etc are among the important basic distinguishing features of programming languages. Variable scope is another that inspires posts here.

For example, many languages have a `import` keyword. Learning a new language and assuming the semantics of `import` are equivalent is fraught with peril.

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [January 25, 2021, 5:53pm UTC](https://discourse.julialang.org/t/confused-about-intent-of-using-import-docs/53834/5 "2021-01-25T17:53:46Z")

</div>

I also praise your dedication on being precise, but I really did not understood what exactly you were reaching for; if it is “permission” to do a PR I think you should just go for it. Six days ago I did see minor imprecision in a `eval`/scope phase of the documentation, opened a [PR](https://github.com/JuliaLang/julia/pull/39317#event-4224731906) just to change the ending of the phrase, and Stefan just approved and merged it right after. I think that if it is clear to you what should be amended, just open a PR and let the maintainers give a look at it.

---

<div class="post-metadata">

**Author:** ![MA\_Laforge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ma_laforge/32/385_2.png) [@MA\_Laforge](https://discourse.julialang.org/u/MA_Laforge)\
**Post date:** [January 26, 2021, 3:16pm UTC](https://discourse.julialang.org/t/confused-about-intent-of-using-import-docs/53834/6 "2021-01-26T15:16:06Z")

</div>

That’s probably the easiest thing to do @Henrique_Becker.

I don’t like the idea of potentially undoing someone’s work, but I guess you are right: someone with more insight will probably intervene if my changes are inaccurate. Thanks.
