# Syntax error when interpolating a quoted operator into a quoted expression

**URL:** <https://discourse.julialang.org/t/syntax-error-when-interpolating-a-quoted-operator-into-a-quoted-expression/90217>\
**Category:** General Usage\
**Tags:** metaprogramming\
**Created:** [November 14, 2022, 2:02am UTC](https://discourse.julialang.org/t/syntax-error-when-interpolating-a-quoted-operator-into-a-quoted-expression/90217 "2022-11-14T02:02:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [November 14, 2022, 2:02am UTC](https://discourse.julialang.org/t/syntax-error-when-interpolating-a-quoted-operator-into-a-quoted-expression/90217/1 "2022-11-14T02:02:00Z")

</div>

I thought I understood how expression interpolation worked. This works as expected:

```julia
julia> sym = :a
:a

julia> :(b > $sym)
:(b > a)

```

But when I try to interpolate an operator into an expression, I get a weird syntax error:

```julia
julia> op = :-
:-

julia> :(1 $op 2)
ERROR: syntax: missing comma or ) in argument list

julia> op = :<
:<

julia> :(1 $op 2)
ERROR: syntax: missing comma or ) in argument list

```

Can anyone explain what’s going on here?

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [November 14, 2022, 2:18am UTC](https://discourse.julialang.org/t/syntax-error-when-interpolating-a-quoted-operator-into-a-quoted-expression/90217/2 "2022-11-14T02:18:42Z")

</div>

You can’t interpolate using infix notation. Do instead:

```julia
julia> op = :-
:-

julia> :($op(1, 2))
:(1 - 2)

```

---

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [November 14, 2022, 2:29am UTC](https://discourse.julialang.org/t/syntax-error-when-interpolating-a-quoted-operator-into-a-quoted-expression/90217/3 "2022-11-14T02:29:57Z")

</div>

Thanks! Good to know.

Any idea why that’s not allowed?

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [November 14, 2022, 2:52am UTC](https://discourse.julialang.org/t/syntax-error-when-interpolating-a-quoted-operator-into-a-quoted-expression/90217/4 "2022-11-14T02:52:56Z")

</div>

> Any idea why that’s not allowed?

I guess (without any deep understanding of what’s going on) interpolation happens after lowering.

So `:(b > $sym)` is first lowered to `:(>(b, $sym))` and then interpolation happens. Whereas `:(1 $op 2)` is invalid syntax because it doesn’t recognize `$op` as an infix operator.
