# Calling a macro from within a macro, revisited

**URL:** <https://discourse.julialang.org/t/calling-a-macro-from-within-a-macro-revisited/19680>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 15, 2019, 10:27pm UTC](https://discourse.julialang.org/t/calling-a-macro-from-within-a-macro-revisited/19680 "2019-01-15T22:27:01Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![johnomotani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnomotani/32/26753_2.png) [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Post date:** [July 31, 2021, 3:53pm UTC](https://discourse.julialang.org/t/calling-a-macro-from-within-a-macro-revisited/19680/15 "2021-07-31T15:53:07Z")

</div>

I know this is an old thread, but I’ve ended up back here a few times, so I think it might be useful to add on. I saw that the `@simd` macro uses an `esc()` outside the entire expression like this: [https://github.com/JuliaLang/julia/blob/1b93d53fc4bb59350ada898038ed4de2994cce33/base/simdloop.jl#L127-L129](https://github.com/JuliaLang/julia/blob/1b93d53fc4bb59350ada898038ed4de2994cce33/base/simdloop.jl#L127-L129)

Following a similar pattern seems to work for wrapping `@simd`. I have a macro

```julia
macro innerloop(ex)
    return esc( :( @simd ivdep $ex ) )
end

```

so I can change the macros applied to inner loops throughout my code. It seems to be working at first glance. Not sure if it’s a general solution, and I confess I’m fairly new to Julia and not really comfortable with how macros/metaprogramming work - should this work? Anyone have comments?

---

_[View the full topic](https://discourse.julialang.org/t/calling-a-macro-from-within-a-macro-revisited/19680)._
