What controls if a an operator 1⊕2⊕3 is varadic

Contrast how + parses vs a custom operator:


julia> dump(:(1+2+3))
Expr
  head: Symbol call
  args: Array{Any}((4,))
    1: Symbol +
    2: Int64 1
    3: Int64 2
    4: Int64 3

it becomes +(1,2,3)

julia> dump(:(1⊕2⊕3))
Expr
  head: Symbol call
  args: Array{Any}((3,))
    1: Symbol ⊕
    2: Expr
      head: Symbol call
      args: Array{Any}((3,))
        1: Symbol ⊕
        2: Int64 1
        3: Int64 2
    3: Int64 3

it becomes ⊕(⊕(1,2),3).

* does it also
Is it just + and * that is special?
or is there a unicode category that does this?

https://docs.julialang.org/en/v1/devdocs/ast/#Operators

Some operators ( + and * ) use N-ary parsing; chained calls are parsed as a single N-argument call.

6 Likes

So it it literally just those two? They are not examples, that is the full list?

2 Likes

++ as well I believe

https://github.com/JuliaLang/julia/blob/44b55d15842ae13744cc12689197a918a1e4b17b/src/julia-parser.scm#L912

3 Likes