# I'm confused with types names

**URL:** https://discourse.julialang.org/t/im-confused-with-types-names/21795
**Category:** General Usage
**Tags:** data\_structures
**Created:** [March 12, 2019, 9:36pm UTC](https://discourse.julialang.org/t/im-confused-with-types-names/21795 "2019-03-12T21:36:55Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Jomtek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jomtek/32/7393_2.png) [@Jomtek](https://discourse.julialang.org/u/Jomtek)
#### Post date: [March 12, 2019, 9:36pm UTC](https://discourse.julialang.org/t/im-confused-with-types-names/21795/1 "2019-03-12T21:36:55Z")

</div>

Imagine I have three files.

**file1.jl**

```julia
module myFirstModule
    struct MyStruct
        attribute :: String
    end
end

```

**file2.jl**

```julia
module mySecondModule
    include("file1.jl")
    include("file3.jl")
    myThirdModule.hello(myFirstModule.MyStruct("a"))
end

```

**file3.jl**

```julia
module myThirdModule
    include("file1.jl")
    function hello(arg)
        println("argument : ", arg)
        println("isa test : ", isa(arg, myFirstModule.MyStruct))
    end
end

```

Well, there, the second module creates an instance of myStruct, and calls the “hello” function from the third module with that instance as an argument.

That is the console output :

```julia
argument : Main.mySecondModule.myFirstModule.MyStruct("a")
isa test : false

```

As you can see, the result of the isa test is **false**.

This acutally means that **arg**'s type isn’t **myFirstModule.MyStruct** , but when I print **arg** , as you can see I’m getting this : `Main.mySecondModule.myFirstModule.MyStruct("a")`

Does it mean that **myFirstModule.MyStruct**!= **Main.mySecondModule.myFirstModule.MyStruct**?

---

<div class="post-metadata">

### Author: ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)
#### Post date: [March 12, 2019, 9:49pm UTC](https://discourse.julialang.org/t/im-confused-with-types-names/21795/2 "2019-03-12T21:49:40Z")

</div>

These are 2 different modules. Here is a MWE:

```julia
julia> module A
           module B end
           module C
               module B end
           end
       end
Main.A

julia> A.B == A.C.B
false

```

Just because they have the same name and content, doesn’t make them the same module.

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [March 12, 2019, 9:50pm UTC](https://discourse.julialang.org/t/im-confused-with-types-names/21795/3 "2019-03-12T21:50:13Z")

</div>

Yes. You should in 99.999% of the cases never include the same file twice. Include the files in the top module and refer to types from there.

---

<div class="post-metadata">

### Author: ![Jomtek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jomtek/32/7393_2.png) [@Jomtek](https://discourse.julialang.org/u/Jomtek)
#### Post date: [March 12, 2019, 10:25pm UTC](https://discourse.julialang.org/t/im-confused-with-types-names/21795/4 "2019-03-12T22:25:13Z")

</div>

I can’t see how you would refer to types of a top module without including it.  
I mean, if you have more than 3 modules, it would give something like that : `Main.mainf.X.X1.X2.X3`

---

<div class="post-metadata">

### Author: ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)
#### Post date: [March 12, 2019, 11:56pm UTC](https://discourse.julialang.org/t/im-confused-with-types-names/21795/5 "2019-03-12T23:56:12Z")

</div>

> [@Jomtek](#):
>
> Does it mean that **myFirstModule.MyStruct**!= **Main.mySecondModule.myFirstModule.MyStruct**?

Yes.  
Due to the fact you’ve `include`d it.  
You will also find that

`myFirstModule != mySecondModule.myFirstModule`.

* * *

I think you’ve got off on the wrong track with how modules and includes work.  
Hopefully someone can explain it, well. (alas not me as I must sleep)

---

<div class="post-metadata">

### Author: ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)
#### Post date: [March 13, 2019, 12:03am UTC](https://discourse.julialang.org/t/im-confused-with-types-names/21795/6 "2019-03-13T00:03:09Z")

</div>

> [@Jomtek](#):
>
> I can’t see how you would refer to types of a top module without including it.

Details about how modules work are given in the relevant chapter of the documentation: [Modules](https://docs.julialang.org/en/v1/manual/modules). Of particular interest to you here is the paragraph about [relative and absolute paths](https://docs.julialang.org/en/v1/manual/modules/#Relative-and-absolute-module-paths-1).

Elaborating on your initial example (which I’ve re-written to use shorter names):

```julia
module A
    struct MyStruct end

    # C is used by B, so should be defined before
    module C
        using ..A

        function hello(x)
            @show x
            @show x isa A.MyStruct
            nothing
        end
    end

    # B uses both its "parent" A and its "sibling" C
    module B
        using ..A
        using ..C

        hello() = C.hello(A.MyStruct())
    end
end

```

```julia
julia> A.B.hello()
x = Main.A.MyStruct()
x isa A.MyStruct = true

```
