# How do you drop one quote inside another?

**URL:** <https://discourse.julialang.org/t/how-do-you-drop-one-quote-inside-another/39078>\
**Category:** General Usage\
**Created:** [May 8, 2020, 12:19pm UTC](https://discourse.julialang.org/t/how-do-you-drop-one-quote-inside-another/39078 "2020-05-08T12:19:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [May 8, 2020, 12:19pm UTC](https://discourse.julialang.org/t/how-do-you-drop-one-quote-inside-another/39078/1 "2020-05-08T12:19:21Z")

</div>

In the following pseudocode, is it possible to drop the `foo` quote inside the `fizzbuzz` function?

```julia
bar = quote
  foo = quote
    i = rand()
    j = 7
  end

  function fizzbuzz()
    # want foo here
    k = i * j
  end
end

```

  

* * *

For clarity, the following works with `foo` defined outside the `bar` quote:

```julia
foo = quote
  i = rand()
  j = 7
end

bar = quote
  function fizzbuzz()
    $(foo)
    k = i * j
  end
end

```

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [May 8, 2020, 12:38pm UTC](https://discourse.julialang.org/t/how-do-you-drop-one-quote-inside-another/39078/2 "2020-05-08T12:38:55Z")

</div>

```julia
bar = quote
    foo = quote
        i = rand()
        j = 7
    end
    function fizzbuzz()
        eval($foo)
        k = i*j
    end
end

```

---

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [May 8, 2020, 12:44pm UTC](https://discourse.julialang.org/t/how-do-you-drop-one-quote-inside-another/39078/3 "2020-05-08T12:44:53Z")

</div>

`eval` won’t work because it operates on a module scope (i.e. it won’t have access to [function](https://github.com/JuliaLang/julia/issues/2386) variables)

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [May 8, 2020, 1:13pm UTC](https://discourse.julialang.org/t/how-do-you-drop-one-quote-inside-another/39078/4 "2020-05-08T13:13:15Z")

</div>

Another try:

This also avoids `foo` to be expanded too early. But `bar` now does not express the function `fizzbuzz`, but yet another expression, so maybe this won’t work for you either. (Actually, it is more or less the same as the working version that you wrote initially, but wrapped into another expression.)

```julia
bar = quote
    foo = quote
        i = rand()
        j = 7
    end
    
    quote
        function fizzbuzz()
            $foo;
            k = i*j
        end
    end
end

```

---

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [May 9, 2020, 11:55am UTC](https://discourse.julialang.org/t/how-do-you-drop-one-quote-inside-another/39078/5 "2020-05-09T11:55:06Z")

</div>

Solid effort, but the real answer I guess was that you have to flip the problem on its head?

The way I got around this situation is copying the work of [InteractNext.jl](https://github.com/JuliaGizmos/InteractNext.jl/blob/master/src/manipulate.jl#L12-L22)
