# Get \`@amacro x 3\` to produce \`\[(:x, x), (:3, 3)\]\` -- a version of \`@show\`

**URL:** <https://discourse.julialang.org/t/get-amacro-x-3-to-produce-x-x-3-3-a-version-of-show/4311>\
**Category:** General Usage\
**Tags:** question, macros\
**Created:** [June 16, 2017, 5:14pm UTC](https://discourse.julialang.org/t/get-amacro-x-3-to-produce-x-x-3-3-a-version-of-show/4311 "2017-06-16T17:14:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![prolixobora](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@prolixobora](https://discourse.julialang.org/u/prolixobora)\
**Post date:** [June 16, 2017, 5:14pm UTC](https://discourse.julialang.org/t/get-amacro-x-3-to-produce-x-x-3-3-a-version-of-show/4311/1 "2017-06-16T17:14:46Z")

</div>

I want a macro that behaves as follows:

```julia
julia> x=7; @amacro x x+x 3
[(:x, 7), (:(x+x), 14), (:3, 3)]

julia> x=7; macroexpand(:( @amacro x x+x 3 ))
[(:x, x), (:(x+x), x+x, (:3, 3)]

```

I think you can consider this a variant of `@show` that doesn’t quite print anything but includes all the information.

So far I have the two “orthogonal” pieces working (except for a `3` where there should be a `:3`)

```julia
julia> macro parta(exs...)
           Expr(:vect, [:($(ex), $(ex)) for ex in exs]...)
       end
@parta (macro with 1 method)

julia> macro partb(exs...)
           Expr(:vect, [(ex, ex) for ex in exs]...)
       end
@partb (macro with 1 method)

julia> x = 7; @parta x x+x 3
3-element Array{Tuple{Int64,Int64},1}:
 (7,7)  
 (14,14)
 (3,3)  

julia> x = 7; @partb x x+x 3
3-element Array{Tuple{Any,Any},1}:
 (:x,:x)            
 (:(x + x),:(x + x))
 (3,3)   

```

But I do not see how to combine these. I’ve tried monkeying a few compositions of `Symbol`, `esc`s, and `$` with no success.

At first I was trying to make this macro look like

```julia
macro amacro
    :[(ex, ... stuff) for ex in exs]
end

```

But the big problem was that I somehow wanted the `[]` to be quoted, without the `for` to be quoted. Now I feel like I am experiencing the same issue with the inner tuples.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [June 16, 2017, 8:01pm UTC](https://discourse.julialang.org/t/get-amacro-x-3-to-produce-x-x-3-3-a-version-of-show/4311/2 "2017-06-16T20:01:37Z")

</div>

This isn’t a complete solution, but I think you might find `QuoteNode` helpful. Here’s my version of `parta`:

```julia
julia> macro parta(exs...)
           Expr(:vect, [Expr(:tuple, QuoteNode(ex), ex) for ex in exs]...)
       end
@parta (macro with 1 method)

julia> x = 5
5

julia> @parta x x+x
2-element Array{Tuple{Any,Int64},1}:
 (:x, 5)
 (:(x + x), 10)

```
