Data.table: Purge <- usage when not strictly necessary

Created on 24 May 2019  ·  3Comments  ·  Source: Rdatatable/data.table

Follow-up to comment here:

https://github.com/Rdatatable/data.table/pull/3582#discussion_r287075480

Also added to Contributing

There's a decent amount of manual clean-up to do, unless someone has as better regex for catching the valid <- usages:

grep -r "<-" R | wc -l
628

I wonder how feasible it is to just blanket replace & then patch in the = that cause errors because <- is required 🤔

Low beginner-task internals

Most helpful comment

Like @jangorecki, I don't think I would have put effort into this either. But now Michael has, it's quite nice to get this out of the way; it's higher value than I thought. It should make PRs easier/faster, particularly as we see new contributors hopefully.
Using =, we don't need to worry about the danger of x<-3 when x < -3 was meant. And since assignment is a function in R which has a value (and -3 is coerced to TRUE silently), this error can go undetected. Using = we don't need to implement and maintain quality control checks to ensure spaces are around every operator. I wonder how many of the people who've been told to use <-, and are convinced <- is best because all the experts agree so it must be right, realize this.

All 3 comments

IMO this is not really that important stuff. I prefer to use =, but when I see <- around, then I align to style in the file that I am writing to. AFAIR our functions definitions uses <- quite consistently.
There is not really any harm (as opposed to what is being widely preached) to have both, assuming people who read data.table code know R. The harm might be only for newcomers to R language, to whom those preaches are probably targeted to. Can we close this one?

I don't really notice much myself, but the linked comment and this commit: https://github.com/Rdatatable/data.table/pull/3580/commits/50243432f2c20310107989606d56ab52fab28ad4

led me to file this in the spirit of consistency.

Added Low since it's extremely low on importance.

Like @jangorecki, I don't think I would have put effort into this either. But now Michael has, it's quite nice to get this out of the way; it's higher value than I thought. It should make PRs easier/faster, particularly as we see new contributors hopefully.
Using =, we don't need to worry about the danger of x<-3 when x < -3 was meant. And since assignment is a function in R which has a value (and -3 is coerced to TRUE silently), this error can go undetected. Using = we don't need to implement and maintain quality control checks to ensure spaces are around every operator. I wonder how many of the people who've been told to use <-, and are convinced <- is best because all the experts agree so it must be right, realize this.

Was this page helpful?
0 / 5 - 0 ratings