# Get function with macro

**URL:** <https://discourse.julialang.org/t/get-function-with-macro/72819>\
**Category:** General Usage\
**Created:** [December 9, 2021, 11:02am UTC](https://discourse.julialang.org/t/get-function-with-macro/72819 "2021-12-09T11:02:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [December 9, 2021, 11:02am UTC](https://discourse.julialang.org/t/get-function-with-macro/72819/1 "2021-12-09T11:02:08Z")

</div>

How can I get the function object with a macro?

```julia
module C
macro getfunc(sig)
    name = sig.args[1]   
end
export @method, @getfunc
end

module D
using Main.C
function foo()
    1
end
using Test
@test (@getfunc foo()) == foo
end

```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [December 9, 2021, 12:34pm UTC](https://discourse.julialang.org/t/get-function-with-macro/72819/2 "2021-12-09T12:34:22Z")

</div>

> [@jzr](#):
>
> `name = sig.args[1] `

You want `esc(sig.args[1])`, I think.
