# Is it possible to use "←" for assignment?

**URL:** <https://discourse.julialang.org/t/is-it-possible-to-use-for-assignment/2973>\
**Category:** General Usage\
**Created:** [March 30, 2017, 5:05pm UTC](https://discourse.julialang.org/t/is-it-possible-to-use-for-assignment/2973 "2017-03-30T17:05:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [March 30, 2017, 5:05pm UTC](https://discourse.julialang.org/t/is-it-possible-to-use-for-assignment/2973/1 "2017-03-30T17:05:11Z")

</div>

Recently I was implementing some code following a paper that used the notation “←” for assignment, e.g.

```julia
a ← b + c

```

Since this is a common notation in computer science, it would be useful to be able to use this in Julia as an alias for “=”.

As far as I understand, this would require modifying the parser. If so, would this be acceptable?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [March 30, 2017, 5:18pm UTC](https://discourse.julialang.org/t/is-it-possible-to-use-for-assignment/2973/2 "2017-03-30T17:18:22Z")

</div>

Having used R before, I always this super confusing:

[https://stat.ethz.ch/R-manual/R-devel/library/base/html/assignOps.html](https://stat.ethz.ch/R-manual/R-devel/library/base/html/assignOps.html)

I know it’s not the same proposal (you’re proposing an alias), but I am just scared of having more than 1 assignment operator after that experience. And it might trip up incoming R users who expect different behaviors out of the operators.

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [March 30, 2017, 6:35pm UTC](https://discourse.julialang.org/t/is-it-possible-to-use-for-assignment/2973/3 "2017-03-30T18:35:59Z")

</div>

Why is it super confusing? TBH I’ve never noticed the difference between `<-` and `=` in R.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [March 30, 2017, 6:42pm UTC](https://discourse.julialang.org/t/is-it-possible-to-use-for-assignment/2973/4 "2017-03-30T18:42:03Z")

</div>

What I really meant is that I would like to be able to assign `←` as an alias for `=` _in my own code_, not really that it should be part of base Julia.

However, since “`=`” is not a normal Julia function, this does not currently seem to be possible, and that’s why it seems like the only option would be to change things at the level of the parser.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [March 30, 2017, 6:43pm UTC](https://discourse.julialang.org/t/is-it-possible-to-use-for-assignment/2973/5 "2017-03-30T18:43:17Z")

</div>

> [@dpsanders](#):
>
> What I really meant is that I would like to be able to assign ← as an alias for = in my own code, not really that it should be part of Julia.

Oh I see. You be you 🙂. Are macros not able to parse `a ← b + c`?

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [March 30, 2017, 6:44pm UTC](https://discourse.julialang.org/t/is-it-possible-to-use-for-assignment/2973/6 "2017-03-30T18:44:48Z")

</div>

> [@ChrisRackauckas](#):
>
> a ← b + c

Yes, a macro would be possible, since it is valid Julia code:

```julia
julia v0.5> parse("a ← b + c")
:(a ← b + c)

julia v0.5> Meta.show_sexpr(ans)
(:call, :←, :a, (:call, :+, :b, :c))

```

Possible, but clunky…

---

<div class="post-metadata">

**Author:** ![malmaud](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/malmaud/32/29_2.png) [@malmaud](https://discourse.julialang.org/u/malmaud)\
**Post date:** [March 30, 2017, 7:09pm UTC](https://discourse.julialang.org/t/is-it-possible-to-use-for-assignment/2973/7 "2017-03-30T19:09:36Z")

</div>

If you use something like `MacroTalks.prewalk`, it’s pretty straightforward to write a macro that can go in front of a whole block of code and transform all instances of `←`.

---

<div class="post-metadata">

**Author:** ![fengyang.wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fengyang.wang/32/104_2.png) [@fengyang.wang](https://discourse.julialang.org/u/fengyang.wang)\
**Post date:** [March 30, 2017, 9:52pm UTC](https://discourse.julialang.org/t/is-it-possible-to-use-for-assignment/2973/8 "2017-03-30T21:52:27Z")

</div>

Note that this would be a breaking change, as there is code that uses `←` for a different purpose.
