# Escape the esc function

**URL:** https://discourse.julialang.org/t/escape-the-esc-function/29524
**Category:** General Usage
**Tags:** question, macros
**Created:** [October 5, 2019, 4:20pm UTC](https://discourse.julialang.org/t/escape-the-esc-function/29524 "2019-10-05T16:20:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Chong\_Wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chong_wang/32/20307_2.png) [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)
#### Post date: [October 5, 2019, 4:20pm UTC](https://discourse.julialang.org/t/escape-the-esc-function/29524/1 "2019-10-05T16:20:39Z")

</div>

It is not uncommon that most of the expression returned by a macro needs to be escaped.

For example

```julia
using MacroTools

const IGNORE = [true]

macro foo(f)
    fdict = MacroTools.splitdef(f)
    fdict[:body] = quote
        if IGNORE[1]
            return nothing
        end
        $(fdict[:body])
    end
    return $(esc(MacroTools.combinedef(dict)))
end

```

Here, I inserted a hook such that the function will not be executed if `IGNORE[1]` is true. `IGNORE` is set to a vector such that I can change the `true` to `false` at runtime.

Clearly, the const `IGNORE` should be resolved in the macro environment. However, it would be rather tedious to manually escape everything else except for `IGNORE`.

Is there a way to somehow label the constant `IGNORE` such that it will not be escaped even it’s inside the `esc` function?

---

<div class="post-metadata">

### Author: ![runapp](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@runapp](https://discourse.julialang.org/u/runapp)
#### Post date: [October 5, 2019, 5:16pm UTC](https://discourse.julialang.org/t/escape-the-esc-function/29524/2 "2019-10-05T17:16:50Z")

</div>

I’m afraid it’s not common enough for a rather complex and dedicated syntax. We already have the powerful AST related structures.
