# RHS or LHS assignment?

**URL:** <https://discourse.julialang.org/t/rhs-or-lhs-assignment/9940>\
**Category:** Internals & Design\
**Tags:** proposal, broadcast\
**Created:** [March 24, 2018, 2:26pm UTC](https://discourse.julialang.org/t/rhs-or-lhs-assignment/9940 "2018-03-24T14:26:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![wood](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wood/32/3735_2.png) [@wood](https://discourse.julialang.org/u/wood)\
**Post date:** [March 24, 2018, 2:26pm UTC](https://discourse.julialang.org/t/rhs-or-lhs-assignment/9940/1 "2018-03-24T14:26:06Z")

</div>

There are extensive discussions about RHS and LHS assignment in Julia github about `=` (see [13168](https://github.com/JuliaLang/julia/issues/13186), [5532](https://github.com/JuliaLang/julia/issues/5532), [7341](https://github.com/JuliaLang/julia/issues/7341) ) and `.=` (see [26516](https://github.com/JuliaLang/julia/issues/26516), [25954](https://github.com/JuliaLang/julia/issues/25954), [26088](https://github.com/JuliaLang/julia/pull/26088), [26347](https://github.com/JuliaLang/julia/pull/26347)).

But it seems that these are still controversial. I think it would be good to listen to the response of the community.

Which do you prefer in terms of the return of `=` operation?

_Poll ([view on site](https://discourse.julialang.org/t/rhs-or-lhs-assignment/9940/1))_

Which do you prefer in terms of the return of `.=` operation?

_Poll ([view on site](https://discourse.julialang.org/t/rhs-or-lhs-assignment/9940/1))_

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [March 24, 2018, 2:30pm UTC](https://discourse.julialang.org/t/rhs-or-lhs-assignment/9940/2 "2018-03-24T14:30:34Z")

</div>

You should probably add `nothing` as an option for `.=` since that’s being discussed as a real option.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [March 24, 2018, 2:43pm UTC](https://discourse.julialang.org/t/rhs-or-lhs-assignment/9940/3 "2018-03-24T14:43:57Z")

</div>

Should there also be an option “I haven’t thought about it enough to make a well-informed opinion”?

---

<div class="post-metadata">

**Author:** ![Keno](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/keno/32/285_2.png) [@Keno](https://discourse.julialang.org/u/Keno)\
**Post date:** [March 24, 2018, 2:48pm UTC](https://discourse.julialang.org/t/rhs-or-lhs-assignment/9940/4 "2018-03-24T14:48:28Z")

</div>

I’m sorry, but these things don’t get decided by popularity poll. If you have carefully considered technical arguments that aren’t in those issues yet for why one should be preferred over the other, please make them.

---

<div class="post-metadata">

**Author:** ![wood](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wood/32/3735_2.png) [@wood](https://discourse.julialang.org/u/wood)\
**Post date:** [March 24, 2018, 3:18pm UTC](https://discourse.julialang.org/t/rhs-or-lhs-assignment/9940/5 "2018-03-24T15:18:10Z")

</div>

Actually I see that there is no right or wrong for the both choices. It is more about how the user expect, desire. I did not really convinced by `RHS` for both `=` and `.=`.

Chained assignment is considered the most important motivation of RHS for `=` to avoid unwanted type convention. But is `RHS` really better than `LHS` in this case?

For the expression `a = b = c = 1`, as previously discussed in the slack, if `c::Float64`, the return of RHS and LHS is different. If `a` and `b` do not have explicit type notation, they will have the same type of `c` in LHS rule, but not in the RHS rule. If `a` or `b` does have explicit type, then it will have the same result in both LHS and RHS.

Another point is the return in REPL, for the expression `a[:] = 4`, it returns 4. I definitely know the value of RHS. What I concerns is what is the value of LHS. So return the LHS is more intuitive.

For the return of `.=`, I also agree more with @stevengj said in [26088](https://github.com/JuliaLang/julia/pull/26088) and [25954](https://github.com/JuliaLang/julia/issues/25954) (prefer LHS as well).

For the return of `A[I].=B`, I am OK for eight return of `A` or `A[I]` when that is decided.

I am not experienced in Julia than most of the members. I may have errors in this statement. It would be good to have more people thinking about this issue.

---

<div class="post-metadata">

**Author:** ![wood](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wood/32/3735_2.png) [@wood](https://discourse.julialang.org/u/wood)\
**Post date:** [March 24, 2018, 3:23pm UTC](https://discourse.julialang.org/t/rhs-or-lhs-assignment/9940/6 "2018-03-24T15:23:42Z")

</div>

Sorry, I cannot edit the poll any more because of exceeding the first 5 min. Could you add another option of `No clue` or something else like that?

---

<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 24, 2018, 3:47pm UTC](https://discourse.julialang.org/t/rhs-or-lhs-assignment/9940/7 "2018-03-24T15:47:27Z")

</div>

Since this is mainly a technical argument which is already taking place where it should, I am not sure what you meant to accomplish with this poll.

---

<div class="post-metadata">

**Author:** ![wood](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wood/32/3735_2.png) [@wood](https://discourse.julialang.org/u/wood)\
**Post date:** [March 24, 2018, 4:07pm UTC](https://discourse.julialang.org/t/rhs-or-lhs-assignment/9940/8 "2018-03-24T16:07:57Z")

</div>

IThe motivation is that it seems nobody can really convince others especially in the discussion of issue 26516. I think it would be good to have more people know about this. It is technical but also practical.

If many think this is meaningless, I am fine to delete it.

---

<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 24, 2018, 4:46pm UTC](https://discourse.julialang.org/t/rhs-or-lhs-assignment/9940/9 "2018-03-24T16:46:32Z")

</div>

Designing semantics for programming languages is difficult and takes time. Please be patient, some issues take months (or even years) to be solved.
