# What does this syntax (using .Filename) mean?

**URL:** <https://discourse.julialang.org/t/what-does-this-syntax-using-filename-mean/59420>\
**Category:** New to Julia\
**Created:** [April 16, 2021, 3:10pm UTC](https://discourse.julialang.org/t/what-does-this-syntax-using-filename-mean/59420 "2021-04-16T15:10:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@Thomas](https://discourse.julialang.org/u/Thomas)\
**Post date:** [April 16, 2021, 3:10pm UTC](https://discourse.julialang.org/t/what-does-this-syntax-using-filename-mean/59420/1 "2021-04-16T15:10:04Z")

</div>

Can someone explain this syntax (in REPL)?

```julia
include("Filename.jl")
using .Filename

```

I can sort of understand the first, but what is the . in front of Filename mean?

---

<div class="post-metadata">

**Author:** ![purplishrock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/purplishrock/32/13451_2.png) [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Post date:** [April 16, 2021, 3:29pm UTC](https://discourse.julialang.org/t/what-does-this-syntax-using-filename-mean/59420/2 "2021-04-16T15:29:16Z")

</div>

I’ve not used that format before, but a quick read of the module documentation indicates that you can access module hierarchy’s using the “.” notation. LOL, I didn’t even know you could have submodules !

[https://docs.julialang.org/en/v1/manual/modules/#Submodules-and-relative-paths](https://docs.julialang.org/en/v1/manual/modules/#Submodules-and-relative-paths)

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [April 16, 2021, 3:49pm UTC](https://discourse.julialang.org/t/what-does-this-syntax-using-filename-mean/59420/3 "2021-04-16T15:49:57Z")

</div>

Actually the filename has nothing to do with `using .Filename`. `Filename` is expected to be a module defined in the file.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [April 16, 2021, 4:04pm UTC](https://discourse.julialang.org/t/what-does-this-syntax-using-filename-mean/59420/4 "2021-04-16T16:04:51Z")

</div>

You can see the effect of `using .ModuleName` without needing to worry about `include` at all. Here’s a simple example:

```julia
julia> module MyModule
         export foo
         
         foo() = println("hello world")
       end
Main.MyModule

```

Here I’ve defined a module which exports one function (`foo`). But I’ve only _defined_ that module, I haven’t `using`-ed it, so I don’t yet have access to that exported function:

```julia
julia> foo
ERROR: UndefVarError: foo not defined

```

To get `foo` into my current namespace, I need `using`. But if I just do `using MyModule`, it doesn’t work:

```julia
julia> using MyModule
ERROR: ArgumentError: Package MyModule not found in current path:

```

That’s because `using MyModule` tells Julia to look for some module with that name in a file in the `LOAD_PATH` or in the current package environment. That’s not what we want–we already defined that module.

Instead, we can do `using .MyModule` which says "find a module named `MyModule` which is already defined in the current namespace (in this case, in `Main`), and activate it:

```julia
julia> using .MyModule

julia> foo()
hello world

```

You can add additional dots to activate modules in a parent module:

```julia
julia> module A
         export bar
         
         bar() = println("bar")
         
         module B
           using ..A
           
           function f()
             println("Calling `bar` which was defined in the parent module `A`:")
             bar()
           end
         end
       end
Main.A

julia> A.B.f()
Calling `bar` which was defined in the parent module `A`:
bar

```
