# Is there a trick to input an \`Expr\` into a macro?

**URL:** https://discourse.julialang.org/t/is-there-a-trick-to-input-an-expr-into-a-macro/82383
**Category:** General Usage
**Tags:** macros
**Created:** [June 7, 2022, 6:16pm UTC](https://discourse.julialang.org/t/is-there-a-trick-to-input-an-expr-into-a-macro/82383 "2022-06-07T18:16:26Z")
**Posts on this page:** 1
**Showing post:** 5

<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: [June 7, 2022, 11:51pm UTC](https://discourse.julialang.org/t/is-there-a-trick-to-input-an-expr-into-a-macro/82383/5 "2022-06-07T23:51:12Z")

</div>

Given a macro `@something` you can get the actual macro object by writing `var"@something"` and from that you can inspect it’s methods and call it. For example:

```julia
julia> macro do_nothing(ex)
           ex
       end
@do_nothing (macro with 1 method)

julia> methods(var"@do_nothing")
# 1 method for macro "@do_nothing":
[1] var"@do_nothing"( __source__ ::LineNumberNode, __module__ ::Module, ex) in Main at REPL[13]:1

```

This says that `var"@do_nothing"` has a method that takes in `LineNumberNode` and `Module` telling you where the macro was invoked, and an expression that it operates on. If you provide this stuff, you can run the macro on a runtime `Expr` and get out an `Expr`. For example,

```julia
julia> var"@do_nothing"(LineNumberNode(@ __LINE__ (), @ __FILE__ ()), @ __MODULE__ (), :(x + 1))
:(x + 1)

```

---

_[View the full topic](https://discourse.julialang.org/t/is-there-a-trick-to-input-an-expr-into-a-macro/82383)._
