News for hackers. Stuff that matters.
Re:Ruby adds experimental support for rightward assignments by throwaway4007 on Thursday September 10, 2020 @03:53PM (#24435901)
>R language also has a similar way of doing this 42 -> age.

Ah yes, the R language, a model of clarity, beauty and lightness in the world of programming languages. Truly an example to follow.

(And it's not like anyone ever uses that "feature" in the R world either.)

Re:Ruby adds experimental support for rightward assignments by jghn on Thursday September 10, 2020 @06:54PM (#24437417)
If you're interactively exploring data using the REPL it can be quite handy.

You do have the correct sentiment in that for actual code meant to be distributed to other human beings it's almost never a good idea to use it although I've seen use cases, particularly involving Tidyverse constructs, where it arguably makes sense.

Re:Ruby adds experimental support for rightward assignments by bachmeier on Thursday September 10, 2020 @04:49PM (#24436437)
shrug

I've used it. The overloading of the equals sign is something that has never made sense for assignment. (Seriously, it's hard to intentionally come up with dumber notation than x = x+1.) I do use -> sometimes. It's more natural to do the evaluation and then figure out where you're going to store the result (particularly when you're programming).

This is minor as these things go. Definitely not a big deal one way or the other.

Re:Ruby adds experimental support for rightward assignments by actuator on Thursday September 10, 2020 @09:21PM (#24438252)
If assignment is what we are concerned about, we should introduce something like `x := x + 1`.
Re:Ruby adds experimental support for rightward assignments by jghn on Thursday September 10, 2020 @09:41PM (#24438364)
why `:=` and not `<-`?

The `<-` in R comes from the APL keyboard, and that glyph is an assignment in APL. It wasn't just some crazy invention from Ross & Robert or even John Chambers.

Re:Ruby adds experimental support for rightward assignments by _kst_ on Thursday September 10, 2020 @10:55PM (#24438723)
Is "x<-3" an assignment to x or a comparison of x to -3?

The same problem led early C (pre-K&R1) to change its compound assignment operators from "=op" to "op=". In early C, "x = -3" assigned the value -3 to x (as it does now), but "x=-3" meant "x = x - 3" (now written "x-=3").

Re:Ruby adds experimental support for rightward assignments by actuator on Thursday September 10, 2020 @10:45PM (#24438676)
Left side assignment is still used to us, from maths and most other programming languages, so it keeps things familar.

The `:=` has been in use in other langs like MySQL

Re:Ruby adds experimental support for rightward assignments by thrwn_frthr_awy on Thursday September 10, 2020 @06:37PM (#24437282)
I don't understand what point you are trying to make here. Do you not like the feature simply because R has a similar feature? Why not look at examples given here and by others and decide/comment on whether it adds clarity or expressiveness or not?
Re:Ruby adds experimental support for rightward assignments by throwaway4007 on Thursday September 10, 2020 @07:03PM (#24437496)
I am making two points:

-Arguing that adding a feature is ok because "R does it" is comically wrong when one is acquainted with all of R's warts and superfluous stuff

-Not even the R world uses that feature either, so we have actual empirical evidence that it's not that helpful to developers.

Re:Ruby adds experimental support for rightward assignments by thrwn_frthr_awy on Thursday September 10, 2020 @07:11PM (#24437558)
I wouldn't say an additional notes section at the end of article showing that is syntax is not unprecedented is an argument that the feature is ok because R does it. The author is simply giving additional context to allow readers to form their own opinion.

It's fine to not like the feature–I don't know enough about its usecase to feel one way of another–but your comment felt unnecessarily negative without adding much to the discussion.

Knowing that R users have access to these syntax and choose not to use it is interesting to consider, but that was overshadowed by your first statement.

Re:Ruby adds experimental support for rightward assignments by FridgeSeal on Thursday September 10, 2020 @07:16PM (#24437597)
R is a very...haphazard language. Not to say it isn't elegant in places, but I wouldn't describe it as a consistent, well planned language. I suspect it's not the rightward assignment OP has an issue with, but the fact that they're looking at R as an example to follow.