# Escaping in a macro

**URL:** <https://discourse.julialang.org/t/escaping-in-a-macro/14543>\
**Category:** General Usage\
**Created:** [September 4, 2018, 3:24pm UTC](https://discourse.julialang.org/t/escaping-in-a-macro/14543 "2018-09-04T15:24:11Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [September 4, 2018, 6:23pm UTC](https://discourse.julialang.org/t/escaping-in-a-macro/14543/21 "2018-09-04T18:23:36Z")

</div>

> [@LaszloH](#):
>
> Accordingly, (and those are the examples given) you can write a, (exp), and $:(expr).

Not just that. `""` is a literal and in general, any expressions could be interpolated some will need `()`.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [September 4, 2018, 6:24pm UTC](https://discourse.julialang.org/t/escaping-in-a-macro/14543/22 "2018-09-04T18:24:40Z")

</div>

> [@LaszloH](#):
>
> you can write `$a`, `$(exp)`, and `$:(expr)`.
> 
> There is nothing about the construct of $“…”.

Any value can take place of `a` in `$a`, including `"..."`. This is not a separate construct. I prefer `$("...")` though for readability, but `()`s are optional.

---

<div class="post-metadata">

**Author:** ![LaszloH](https://avatars.discourse-cdn.com/v4/letter/l/fbc32d/32.png) [@LaszloH](https://discourse.julialang.org/u/LaszloH)\
**Post date:** [September 4, 2018, 6:33pm UTC](https://discourse.julialang.org/t/escaping-in-a-macro/14543/23 "2018-09-04T18:33:47Z")

</div>

Thank all of you! I learned (which are not in the documentation):

1. Interpolation of expressions sometimes does not need parentheses, other times it does.
2. esc() can occur anywhere in a macro, not just in the context of a return expression.
3. Macros are more tricky than what you expect.

I try to remember…

---

<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:** [September 4, 2018, 6:38pm UTC](https://discourse.julialang.org/t/escaping-in-a-macro/14543/24 "2018-09-04T18:38:58Z")

</div>

This is open source, and open source only improves through the work of its contributors. The single most effective thing you can do to make Julia’s macro documentation better is to open a pull request with suggestions for changes or improvements. The only barrier to being a contributor to Julia itself is the willingness to do so.

---

<div class="post-metadata">

**Author:** ![Pbellive](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbellive/32/3604_2.png) [@Pbellive](https://discourse.julialang.org/u/Pbellive)\
**Post date:** [September 4, 2018, 11:00pm UTC](https://discourse.julialang.org/t/escaping-in-a-macro/14543/25 "2018-09-04T23:00:57Z")

</div>

There was a workshop titled “A Practical Introduction to Metaprogramming in Julia” At this year’s JuliaCon. Find it on YouTube at:

[![](https://global.discourse-cdn.com/julialang/original/3X/8/a/8a83d08ef8a81f11eef844da48346237d2a9432e.jpeg "JuliaCon 2018 | A practical introduction to metaprogramming in Julia | Andy Ferris") ](https://www.youtube.com/watch?v=SeqAQHKLNj4)

I haven’t watched it (it’s on my to-do list) so I can’t vouch for its quality but it might be a good resource that compliments the manual.

---

<div class="post-metadata">

**Author:** ![js135005](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/js135005/32/8219_2.png) [@js135005](https://discourse.julialang.org/u/js135005)\
**Post date:** [September 4, 2018, 11:17pm UTC](https://discourse.julialang.org/t/escaping-in-a-macro/14543/26 "2018-09-04T23:17:56Z")

</div>

Actually it doesn’t talk about macros at all but is well worth watching for its insights into how Julia operates behind the scenes.

[Previous page](https://discourse.julialang.org/t/escaping-in-a-macro/14543.md?page=1)
