zeallot icon indicating copy to clipboard operation
zeallot copied to clipboard

Could an second variation on the operator be created so it doesn't with %<-% from future

Open UnclAlDeveloper opened this issue 5 years ago • 6 comments

Since %<-% is also used by future and the usage of namespaces with operators is a little messy zeallot::%<-%(c(a, b), c(1, 2)) to differentiate between the different overrides of the operator, could a second alternative variation be created. It's a really useful operator, adding one of the pieces of functionality that r misses vs python. For my own use I've cloned and changed the operator to %<-c%, but I guess anything would work.

UnclAlDeveloper avatar Apr 14 '20 13:04 UnclAlDeveloper

I'm not particularly familiar with the {future} package, is the %<-% operator required for certain {future} functionality?

nteetor avatar Apr 18 '20 22:04 nteetor

Yes. Very much.

I don’t think future is part of tidyverse, but it is certainly part of the direction R is going in, and is already something of a mainstay. Multiple assignment (via zeallot) is something that R definitely lacks, but multiprocessing, which the future package addresses, is considered more important. I’d really recommend changing the %<-% operator to a similar variation, since anyone or any package that uses future will have to avoid any dependency on zeallot.

UnclAlDeveloper avatar Apr 19 '20 18:04 UnclAlDeveloper

I’m assuming nteetor is the developer. If not, this is meant for the developer.

I asked in the OP if a second variant of %<-% could be created, but this would still allow override issues with the future library. Better would be to make it a unique operator. I use %<-c%. Whatever the developer prefers, but I’d really suggest making it unique (not %<-%) so that zeallot can become more mainstream.

UnclAlDeveloper avatar Apr 19 '20 18:04 UnclAlDeveloper

I can appreciate the frustrations of namespace clash. Reading over the "Implicit of Explicit Futures" section found here, https://cran.r-project.org/web/packages/future/vignettes/future-1-overview.html, I see there is an alternative method for {future} that does not require %<-%.

Given that others have requested different changes to the zeallot operator for various reasons, see #29 and #50, I am hesitant to introduce a new operator. This is a slippery slope and I won't be able to make everyone happy.

See HenrikBengtsson/future#207 for the {future}'s author's take on the situation. Unfortunately, {zeallot} was developed and released in the aforementioned %<=% testing phase of {future}. So, at the time, there was no conflict. Since then {future} moved back to %<-%.

That issue also does a good job highlighting why a change to the operator is a poor idea. As I've said before (see #50), I wish multiple assignment were baked into R by default. In the meantime, the %<-% operator is as close to a plain ol' <- as I can get. Hopefully one day we'll all have concise multiple assignment code out of the box.

nteetor avatar Apr 20 '20 13:04 nteetor

Would it be a good idea to suggest the R Core Team add zeallot's functionality into the <- itself? Not sure how this is achievable in Internal C though.

chuckleong21 avatar Jun 18 '20 15:06 chuckleong21

I’d second that. I don’t use python much, but the ability to return / update multiple variables at once From a function call is one of the features that impressed me about it.

UnclAlDeveloper avatar Jun 19 '20 18:06 UnclAlDeveloper