# How to get current module/scope in macro

**URL:** <https://discourse.julialang.org/t/how-to-get-current-module-scope-in-macro/13309>\
**Category:** General Usage\
**Tags:** module, scope\
**Created:** [August 12, 2018, 4:36pm UTC](https://discourse.julialang.org/t/how-to-get-current-module-scope-in-macro/13309 "2018-08-12T16:36:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thautwarm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thautwarm/32/37760_2.png) [@thautwarm](https://discourse.julialang.org/u/thautwarm)\
**Post date:** [August 12, 2018, 4:36pm UTC](https://discourse.julialang.org/t/how-to-get-current-module-scope-in-macro/13309/1 "2018-08-12T16:36:30Z")

</div>

Hi, community.

Could I get the module or scope of the calller of macro in Julia 1.0?

Just like this:

```julia
module SomeModule
macro f()
    S = caller_module.eval(:S)
    fields = fieldnames(S)
   # do something with fields
end

```

```julia
module OtherModule
import SomeModule: @f 
struct S 
    ...
end
function fn(...)
   let staged_analysis = @f
      # do stuff 
  end
end

```

I do know that I can return an escaped macro and it works well in runtime(after macro application and call function), however, I might not be able to be use metadata of types and such stuffs when compiling callers of macro(when applying macro).

Any helps, please?

---

<div class="post-metadata">

**Author:** ![thautwarm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thautwarm/32/37760_2.png) [@thautwarm](https://discourse.julialang.org/u/thautwarm)\
**Post date:** [August 12, 2018, 4:53pm UTC](https://discourse.julialang.org/t/how-to-get-current-module-scope-in-macro/13309/2 "2018-08-12T16:53:33Z")

</div>

Sorry for the double-post by mistakes. The first one is [here](https://discourse.julialang.org/t/how-to-get-current-module-scope-in-macro/13310).

I cannot delete this duplicated one, and thanks a lot if anyone helps me with it.
