# Which operators are parsed as chains?

**URL:** https://discourse.julialang.org/t/which-operators-are-parsed-as-chains/36633
**Category:** General Usage
**Tags:** metaprogramming
**Created:** [March 28, 2020, 11:12am UTC](https://discourse.julialang.org/t/which-operators-are-parsed-as-chains/36633 "2020-03-28T11:12:53Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![phg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phg/32/17184_2.png) [@phg](https://discourse.julialang.org/u/phg)
#### Post date: [March 28, 2020, 11:12am UTC](https://discourse.julialang.org/t/which-operators-are-parsed-as-chains/36633/1 "2020-03-28T11:12:54Z")

</div>

I asked this over at the metaprogramming Slack channel but got no replies, so another try:

I thought all repeated binary operators are parsed as a chain, but apprearently that is not the case:

```julia
julia> Meta.show_sexpr(:(a ⊗ b ⊗ c))
(:call, :⊗, (:call, :⊗, :a, :b), :c)
julia> Meta.show_sexpr(:(a + b + c))
(:call, :+, :a, :b, :c)

```

For which operators exactly does that work?

---

<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: [March 28, 2020, 5:41pm UTC](https://discourse.julialang.org/t/which-operators-are-parsed-as-chains/36633/2 "2020-03-28T17:41:55Z")

</div>

I am not sure it is explicitly documented, but [the source](https://github.com/JuliaLang/julia/blob/712731e1a1e9e85a272343ba2e773707ca90a466/src/julia-parser.scm#L906) suggests that the only operators that do this are `+`, `++,` and `*`.

---

<div class="post-metadata">

### Author: ![phg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phg/32/17184_2.png) [@phg](https://discourse.julialang.org/u/phg)
#### Post date: [March 29, 2020, 3:47pm UTC](https://discourse.julialang.org/t/which-operators-are-parsed-as-chains/36633/3 "2020-03-29T15:47:04Z")

</div>

Oh, intersting, thanks.

What is `++` used for? I think I’ve never seen it, but appearently there’s something to it if it is parsed specially.

---

<div class="post-metadata">

### Author: ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)
#### Post date: [March 29, 2020, 4:09pm UTC](https://discourse.julialang.org/t/which-operators-are-parsed-as-chains/36633/4 "2020-03-29T16:09:41Z")

</div>

It was used for [GitHub - pkofod/PlusPlus.jl](https://github.com/pkofod/PlusPlus.jl) 🙂

---

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [March 29, 2020, 4:50pm UTC](https://discourse.julialang.org/t/which-operators-are-parsed-as-chains/36633/5 "2020-03-29T16:50:31Z")

</div>

It was a potential generic sequence concatenation operator, but that never really took off. The reason for n-ary parsing is because otherwise concatenating many sequences (e.g. strings) would be inefficient, allocating a temporary for each operator.
