# Defining \`--\>\` operator

**URL:** <https://discourse.julialang.org/t/defining-operator/87514>\
**Category:** General Usage\
**Created:** [September 20, 2022, 12:22pm UTC](https://discourse.julialang.org/t/defining-operator/87514 "2022-09-20T12:22:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)\
**Post date:** [September 20, 2022, 12:22pm UTC](https://discourse.julialang.org/t/defining-operator/87514/1 "2022-09-20T12:22:37Z")

</div>

The [NEWS.md for Julia 1.6](https://github.com/JuliaLang/julia/blob/release-1.6/NEWS.md#language-changes) says:

> The `-->` operator now lowers to a `:call` expression, so it can be defined as a function like other operators.

I originally took this to mean that in earlier versions, you had to use the infix syntax to define it, but that doesn’t seem to work:

```julia
julia> a --> b = a + b
ERROR: syntax: invalid assignment location "a --> b" around REPL[3]:1

```

So in versions before Julia 1.6, was `-->` just available as syntax for macros to manipulate, but nothing else? Is it possible to define behaviour for it like you can with other operators, for eg. `a // b = a + b` or `//(a, b) = a + b`, in Julia 1.0 to 1.5?

* * *

PS: The infix definition syntax for `-->` doesn’t work even in current Julia versions, which I think should be a bug? `-->(a, b) = a + b` works in Julia 1.6 and above, but `a --> b = a + b` leads to the same error as above.

---

<div class="post-metadata">

**Author:** ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)\
**Post date:** [September 20, 2022, 12:40pm UTC](https://discourse.julialang.org/t/defining-operator/87514/2 "2022-09-20T12:40:52Z")

</div>

> [@digital\_carver](#):
>
> PS: The infix definition syntax for `-->` doesn’t work even in current Julia versions, which I think should be a bug? `-->(a, b) = a + b` works in Julia 1.6 and above, but `a --> b = a + b` leads to the same error as above.

I guess this is covered by the next part of the NEWS.md

> For backwards compatibility, `-->` still parses using its own expression head instead of `:call`.

Since it doesn’t get parsed as a function call, but as its own special expression, it doesn’t get the usual benefit that the infix-form can be used as a definition. Unfortunate inconsistency (for eg. other arrows like `<--` _can_ be defined with the infix syntax), but one of the sacrifices made for backwards compatibility.

I guess this also kind of answers my original question - the infix syntax in Julia 1.5 and below would also have parsed into this same special expression, so can’t be used to define behaviour for `-->`.

So could someone explain what it means for `-->` to have been available as an operator in Julia \<=1.5? Does it just mean that the parser won’t complain about it, and so in practice the only use for it would be in custom DSL syntax using macros?
