Proposal: Rename lhs and rhs

149 views
Skip to first unread message

Antonio Cangiano

unread,
Jun 26, 2016, 12:38:33 AM6/26/16
to elixir-lang-core
Elixir tends to score quite well on the usability scale, however, displaying lhs and rhs in test results is not really user-friendly.

I would suggest renaming them to more user-friendly options. Someone on Hacker News suggested expected and actualIncidentally, those are the labels used by Clojure. Haskell (HUnit) uses expected and but gotEither would be clearer. It is a small improvement, but every little bit helps.


Thoughts?


Best,
Antonio

Paul Clegg

unread,
Jun 26, 2016, 2:07:04 AM6/26/16
to elixir-l...@googlegroups.com
Which side is "expected" and which side is "actual"?

The assertion is simply that the comparator is "true", and there's a left hand side and a right hand side, it's personal style/taste/choice as to which is the side that has the "actual" and "expected" values.  This might be obvious if there's a constant on one side:

assert x == 5
assert "hello" == x

But less obvious if you're comparing variables:

assert x == y
assert y == x

I favor lhs/rhs, it's unambiguous and doesn't force you to work to someone else's expectations of what side the "expected" value should go on.

...Paul



--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/ba5370e1-c59e-4180-b8fc-a02402828e90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Antonio Cangiano

unread,
Jun 26, 2016, 3:21:43 AM6/26/16
to elixir-lang-core
 
I favor lhs/rhs, it's unambiguous and doesn't force you to work to someone else's expectations of what side the "expected" value should go on.

A convention could be established, as it's been the case in other languages. Nevertheless, I do think that you have a fair point. Then, what do you think of replacing lhs and rhs with the less cryptic left and right? Not that the acronym is hard to guess, but it's still less user-friendly than plain English, IMHO.

Paul Clegg

unread,
Jun 26, 2016, 3:39:34 AM6/26/16
to elixir-l...@googlegroups.com
"left" and "right" is fine by me if others agree it's clearer than "lhs" and "rhs".

...Paul



On Sun, Jun 26, 2016 at 12:21 AM, Antonio Cangiano <acan...@gmail.com> wrote:
 
I favor lhs/rhs, it's unambiguous and doesn't force you to work to someone else's expectations of what side the "expected" value should go on.

A convention could be established, as it's been the case in other languages. Nevertheless, I do think that you have a fair point. Then, what do you think of replacing lhs and rhs with the less cryptic left and right? Not that the acronym is hard to guess, but it's still less user-friendly than plain English, IMHO.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.

Norbert Melzer

unread,
Jun 26, 2016, 4:17:23 AM6/26/16
to elixir-l...@googlegroups.com

Antonio Cangiano writes:

>
>
>> I favor lhs/rhs, it's unambiguous and doesn't force you to work to someone
>> else's expectations of what side the "expected" value should go on.
>>
>
> A convention could be established, as it's been the case in other
> languages.

That convention has established by force, by whomever designed the API
for the testing library in question.

> Nevertheless, I do think that you have a fair point. Then, what do you
> think of replacing lhs and rhs with the less cryptic left and right?

I can read LHS and RHS quite well, but maybe thats because I was used to
that terms from an very early point during my study. We used them all
the time in the mathy lectures.

> Not that the acronym is hard to guess, but it's still less
> user-friendly than plain English, IMHO.

Yeah, I think expanding to `left` and `right` would be much more clear.
Not every user of elixir has studied CS, some might not even speak
english very good.

Filip Haglund

unread,
Jun 26, 2016, 12:12:10 PM6/26/16
to elixir-lang-core
Right could be confused with correct. If the changes happens, make sure the lines still line up, i.e. add an extra space after "left".

Paul Clegg

unread,
Jun 26, 2016, 12:17:49 PM6/26/16
to elixir-l...@googlegroups.com
On Sun, Jun 26, 2016 at 9:12 AM, Filip Haglund <fille....@gmail.com> wrote:
Right could be confused with correct. If the changes happens, make sure the lines still line up, i.e. add an extra space after "left".

So maybe "port" and "starboard"?  :)

...Paul

 

Filip Haglund

unread,
Jun 26, 2016, 12:23:42 PM6/26/16
to elixir-lang-core
west/east? :)

Myron Marston

unread,
Jun 26, 2016, 3:37:31 PM6/26/16
to elixir-lang-core

I don’t thin expected and actual make sense for elixir. With ==, IMO it is most natural to put the expected value on the right hand side:

assert x == 5

The alternative, assert 5 == x, reads like you are asserting something about 5.

But consider assertions with =: in that case, the expected pattern must go on the left side, and the actual value on the right:

assert %{x: 5} = map

So I don’t think we can consistently consider one side or the other of assertions with operators to always be “expected”.

As for left vs right: I’d be OK with that if there’s a broad consensus from the community but prefer lhs and rhs. I don’t remember when I first learned the lhs/rhs terminology but it wasn’t in my CS classes and I’ve seen it in some other programming languages, too (although I forget where now: I’ve seen this terminology often enough that it’s not notable when I see it anymore). I also like that lhs and rhs has the same number of characters, but left and right do not.

Myron

Tallak Tveide

unread,
Jun 28, 2016, 3:56:48 PM6/28/16
to elixir-lang-core
Actually this was thoroughly discussed when lhs rhs was sertled upon. so the current naming was not chosen by accudent, and at the time found the superior option.

I still personally think lhs and rhs is fine, and being shown in the terminal, also quite a few characters less. This may prevent word wrapping.

Wiebe-Marten Wijnja

unread,
Jul 8, 2016, 1:53:15 AM7/8/16
to elixir-lang-core
Even for people that have no prior knowledge of what lhs or rhs mean, I think that their usage in ExUnit's output is self-explanatory. When someone sees a failed test result for the first time, they will instantly be able to see that we're talking about the two sides of the assert statement, even if the abbreviations are new. 

~Wiebe-Marten


On Sunday, June 26, 2016 at 6:38:33 AM UTC+2, Antonio Cangiano wrote:
Reply all
Reply to author
Forward
0 new messages