# Current\_module() vs @\_\_MODULE\_\_ / They are not equivalent

**URL:** <https://discourse.julialang.org/t/current-module-vs-module-they-are-not-equivalent/10373>\
**Category:** General Usage\
**Created:** [April 16, 2018, 8:45pm UTC](https://discourse.julialang.org/t/current-module-vs-module-they-are-not-equivalent/10373 "2018-04-16T20:45:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qiyamah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qiyamah/32/2660_2.png) [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Post date:** [April 16, 2018, 8:45pm UTC](https://discourse.julialang.org/t/current-module-vs-module-they-are-not-equivalent/10373/1 "2018-04-16T20:45:19Z")

</div>

```nohighlight
julia> module XXX
               export foo,bar
               function foo(amod::Module = current_module())
                       println(amod)
               end

               function bar(amod::Module = @ __MODULE__ )
                       println(amod)
               end
       end
Main.XXX

julia> module YYY
               using Main.XXX
               export f,g
               function f()
                       foo()
               end

               function g()
                       bar()
               end
       end
Main.YYY

julia> using Main.YYY

julia> f()
┌ Warning: `current_module()` is deprecated, use `@ __MODULE__ ` instead.
│ caller = foo at REPL[1]:4 [inlined]
└ @ Core REPL[1]:4
Main

julia> g()
Main.XXX

```

How can i get the old current\_module() functionality?

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [April 16, 2018, 8:58pm UTC](https://discourse.julialang.org/t/current-module-vs-module-they-are-not-equivalent/10373/2 "2018-04-16T20:58:26Z")

</div>

There’s no equivalent. The exact fix of this depending on what you are actually using this for at a higher level

---

<div class="post-metadata">

**Author:** ![Qiyamah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qiyamah/32/2660_2.png) [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Post date:** [April 16, 2018, 9:02pm UTC](https://discourse.julialang.org/t/current-module-vs-module-they-are-not-equivalent/10373/3 "2018-04-16T21:02:41Z")

</div>

I am trying to achieve the functionality of foo() which is giving me the module wherever i am calling the function.

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [April 16, 2018, 9:10pm UTC](https://discourse.julialang.org/t/current-module-vs-module-they-are-not-equivalent/10373/4 "2018-04-16T21:10:39Z")

</div>

That is exactly the thing that is not possible. You need to figure out why you need that behavior.

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [April 16, 2018, 9:16pm UTC](https://discourse.julialang.org/t/current-module-vs-module-they-are-not-equivalent/10373/5 "2018-04-16T21:16:20Z")

</div>

Or in another word, what does your function do, what does it operate on the module and why does it care about the module the top-level code is running in.
