tidyverse / magrittr

Improve the readability of R code with the pipe
https://magrittr.tidyverse.org
Other
957 stars 157 forks source link

Suggestion: change pipe-operator names for consistency and clarity #178

Closed prosoitos closed 5 years ago

prosoitos commented 5 years ago

I love magrittr and am teaching the less common pipe-operators in workshops to encourage their use. I find that their long and inconsistent names is not helping students however, and even people who regularly use them never remember their names and have to describe their symbols when referring to them orally. Short and consistent names would (I think) be easier and neater.

Here are the current names:

magrittr forward-pipe operator (note the inconsistent hyphen position)
magrittr compound assignment pipe-operator
magrittr exposition pipe-operator
magrittr tee operator (what happened to the "pipe"?)

I suggest replacing these names with the following:

assignment pipe
compound assignment pipe
exposition pipe
tee pipe

I would be happy to submit a PR if you agree with the change.

hadley commented 5 years ago

That'd be great please

prosoitos commented 5 years ago

I thought the last one was %T%, but it is in fact %T>%. So tee assignment pipe might be more appropriate?

smbache commented 5 years ago

why "assignment"? Nothing is being assigned by any pipe other than %<>%.

prosoitos commented 5 years ago

OK. I see what you mean.

From the term compound assignment, I had understood that you were considering the process of piping as a form of assignment (as in: pipe from lhs to rhs, then re-pipe to lhs). So I understood compound assignment as "double assignment" and I was taking the > or < symbols as a form of assignment (in one direction or the other).

But I now see that the term compound assignment rather meant "pipe and assign" and that the term "assignment" was used in its classic sense.

I just submitted a PR. But I am happy to update all the names to whatever everybody thinks is best.

prosoitos commented 5 years ago

Maybe:

pipe
assignment pipe
exposition pipe
tee pipe

???

smbache commented 5 years ago

“Compound assignment” is the term normally used for this type of functionality, eg += and friends in many languages.

prosoitos commented 5 years ago

OK. Without a background in any other language, I didn't know. Thanks for clarifying. The < and > symbols in %<>% also confused me in my interpretation of the vocabulary use since I didn't know better and since it is the same symbol (in one direction or the other) while they mean different things (piping with > and then assigning back with <).

But it now makes sense and I am happy to update the names to whatever seems best.