A symbol is a Julia identifier form that can name a function. When the name is suitable, the function can also be written between its arguments in infix notation. section 2.5.3
Julia uses several equivalent forms for function calls:
- Prefix form places the function name before its arguments, as in +(3, 4). section 2.5.3
- Infix form places a symbolic function name between two arguments, as in 3 + 4. section 2.5.3
- A regular name such as foo cannot automatically be used in infix form. section 2.5.3
Define an infix operator
Create a function with a symbolic name, then call it either way: ×(a, b) = a^2 + b^2; ×(4, 10) returns 116, and 4 × 10 returns the same result. Type a LaTeX-like abbreviation such as \times and press Tab to enter symbols in the Julia REPL or supported editors. section 2.5.3
Symbols also provide compact programmer-facing text labels. For example, printstyled accepts a color such as :cyan, and Symbol("hello") creates :hello, which compares equal to the literal symbol :hello. section 5.1.1
julia> ×(a, b) = a^2 + b^2 × (generic function with 1 method) julia> ×(4, 10) 116 julia> 4 × 10 116 julia> 2 × 3 13
Compare prefix calls with infix calls for a user-defined symbolic function. section 2.5.3




