# Refer to a function in enclosing module

**URL:** <https://discourse.julialang.org/t/refer-to-a-function-in-enclosing-module/42580>\
**Category:** General Usage\
**Created:** [July 5, 2020, 11:39pm UTC](https://discourse.julialang.org/t/refer-to-a-function-in-enclosing-module/42580 "2020-07-05T23:39:41Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [July 5, 2020, 11:39pm UTC](https://discourse.julialang.org/t/refer-to-a-function-in-enclosing-module/42580/1 "2020-07-05T23:39:41Z")

</div>

This stumps me at the moment: How do I refer to `f` in the submodule?

```julia
module A

f(x) = 10*x

module SubA

g(x) = f(1)

end

end

using .A

@show A.SubA.g(3)

```

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [July 5, 2020, 11:59pm UTC](https://discourse.julialang.org/t/refer-to-a-function-in-enclosing-module/42580/2 "2020-07-05T23:59:44Z")

</div>

You need to pull `f` into `SubA` from `A` like so:

```julia
julia> module A
       f(x) = 10*x

       module SubA
       using ..A: f

       g(x) = f(1)

       end

       end
Main.A

julia> using .A

julia> A.SubA.g(3)
10

```

the `..A` basically means `$EnclosingModule.A` like in unixy directories.

---

<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:** [July 6, 2020, 12:02am UTC](https://discourse.julialang.org/t/refer-to-a-function-in-enclosing-module/42580/3 "2020-07-06T00:02:24Z")

</div>

> [@PetrKryslUCSD](#):
>
> ```julia
> module A
> 
> f(x) = 10*x
> 
> module SubA
> 
> g(x) = f(1)
> 
> end
> 
> end
> 
> using .A
> 
> @show A.SubA.g(3)
> 
> ```

Of course, I’ve used this notation many times before. I don’t know, when I looked at this particular example I couldn’t see it. Silly me.

Thanks.
