# If f = +, why can't I use f as an infix operator (e.g., 2 f 3 == 5)?

**URL:** <https://discourse.julialang.org/t/if-f-why-cant-i-use-f-as-an-infix-operator-e-g-2-f-3-5/66698>\
**Category:** New to Julia\
**Tags:** infix\
**Created:** [August 20, 2021, 1:46am UTC](https://discourse.julialang.org/t/if-f-why-cant-i-use-f-as-an-infix-operator-e-g-2-f-3-5/66698 "2021-08-20T01:46:28Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [August 20, 2021, 2:18am UTC](https://discourse.julialang.org/t/if-f-why-cant-i-use-f-as-an-infix-operator-e-g-2-f-3-5/66698/11 "2021-08-20T02:18:26Z")

</div>

Unfortunately none of us can run that example because none of `push`, `pop` and `S` are defined. If you could provide those and reduce it into a MWE (see [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757/)), we can dig into it.

> [@dgpdx](#):
>
> Why should code that works on the command line not work in code? That conflicts with the entire idea of developing interactively, then putting the checked out code in a file.

I just tried putting this into a file and running it:

```julia
f = +
x, y = 2, 3
println(f(x, y))
println(+(x, y))

```

As expected, it prints out 5 twice.

Edit: to elaborate on @johnmyleswhite’s point, most languages with infix operators (i.e. not lisps or forths) allow a limited number of symbols in infix position. This is a parsing restriction as opposed to a runtime one, so while you can overload the _meaning_ of those symbols, you can not use symbols or identifiers that have not been explicitly allowed by the parser in infix position. There are languages that allow arbitrary infix functions (e.g. Kotlin, Haskell), but they must be escaped with something like `lhs `infixop` rhs` (as opposed to native infix functions, which do not require escaping).

---

_[View the full topic](https://discourse.julialang.org/t/if-f-why-cant-i-use-f-as-an-infix-operator-e-g-2-f-3-5/66698)._
