# Difference between "using x" vs "using .x" or "using Main.x"

**URL:** <https://discourse.julialang.org/t/difference-between-using-x-vs-using-x-or-using-main-x/52269>\
**Category:** General Usage\
**Created:** [December 23, 2020, 11:26am UTC](https://discourse.julialang.org/t/difference-between-using-x-vs-using-x-or-using-main-x/52269 "2020-12-23T11:26:10Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [December 23, 2020, 12:58pm UTC](https://discourse.julialang.org/t/difference-between-using-x-vs-using-x-or-using-main-x/52269/2 "2020-12-23T12:58:50Z")

</div>

I find that a little bit confusing as well. You can think like a directory structure. The packages and `Main` are at the top level of that structure. For the modules which are at the top level, you do not use any dot:

```julia
juila> using Main

julia> using Pkg

```

But when you are inside a module (we are “inside the module `Main`” at the REPL - correct me if this image is wrong), we can refer to the modules in this module using `.` (as to the files in the current directory):

```julia
julia> module Foo
         x = 1
         export x
       end
Main.Foo

```

Up to this point is like if `Foo` was a subdirectory of `Main`, and thus you have to refer to things within it with:

```julia
julia> Foo.x
1

julia> Main.Foo.x
1

```

When you do this, however:

```julia
julia> using .Foo

```

You bring `Foo` to the same level as `Main`.

You can use that “directory image” for understanding nested modules, for example:

```julia
julia> module Foo1
         module Faa1
           x = 1 ; export x
         end
         module Foo2
            module Faa2
              y = 1 ; export y
            end
            module Foo3
               module Faa3
                 z = 1 ; export z
               end
               using .Faa3
               using ..Faa2
               using ...Faa1
               f() = x + y + z
            end 
          end
       end
WARNING: replacing module Foo1.
Main.Foo1

julia> Foo1.Foo2.Foo3.f()
3

```

---

_[View the full topic](https://discourse.julialang.org/t/difference-between-using-x-vs-using-x-or-using-main-x/52269)._
