# Interpolate into macro like BenchmarkTools

**URL:** <https://discourse.julialang.org/t/interpolate-into-macro-like-benchmarktools/18506>\
**Category:** General Usage\
**Tags:** question, macros\
**Created:** [December 10, 2018, 3:55am UTC](https://discourse.julialang.org/t/interpolate-into-macro-like-benchmarktools/18506 "2018-12-10T03:55:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [December 10, 2018, 3:55am UTC](https://discourse.julialang.org/t/interpolate-into-macro-like-benchmarktools/18506/1 "2018-12-10T03:55:43Z")

</div>

With `@btime` it is possible to interpolate values, how can I replicate this in other macros?

```nohighlight
julia> x = 8
8

julia> @btime $x
  0.027 ns (0 allocations: 0 bytes)
8

julia> macro fun(expr)
           return esc(expr)
       end
@fun (macro with 1 method)

julia> @fun $x
ERROR: syntax: "$" expression outside quote

```

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [December 10, 2018, 5:45am UTC](https://discourse.julialang.org/t/interpolate-into-macro-like-benchmarktools/18506/2 "2018-12-10T05:45:42Z")

</div>

The `$` thing is specific to BenchmarkTools:

> <https://github.com/JuliaCI/BenchmarkTools.jl/blob/af35d0513fe1e336ad0d8b9a35f924e8461aefa2/src/execution.jl#L191-L206>
