dgkf / R

An experimental reimagining of R
https://dgkf.github.io/R
GNU General Public License v3.0
135 stars 5 forks source link

Deviations from the R langauge #6

Open dgkf opened 1 year ago

dgkf commented 1 year ago

An ongoing catalog of intentional deviations from R, in varying stages of maturity

Confident

Undecided

Needs Feedback

sebffischer commented 1 year ago

A very minor thing, but it would be great if list(a = 1,) work just like list(a = 1) :D

dgkf commented 1 year ago

A very minor thing, but it would be great if list(a = 1,) work just like list(a = 1) :D

Done!

image

This was a stealth feature, even to me! I only discovered that I baked it in last time it was mentioned over on mastodon. However, I never went back and updated this issue to document it.

One point of contention here is whether to allow arbitrary numbers of empty arguments (list(,,,,,b = 3) or x[, 2]). Still not sure if empty arguments are desirable as meaningful call arguments generally. The only place where I think this really has impact is for axis indexing. Personally, I found R's x[,2] syntax much more confusing at first than python's df.loc[:, 2] and julia's df[:, 2] which both at least have some argument, but that might just be a matter of which language I encountered first. Ultimately they're all expressing the same idea, and R's is definitely the most terse.

sebffischer commented 1 year ago

If I may add a little more to the wishlist, having sub-modules / sub-packages would also be something that I would appreciate quite a bit :)

dgkf commented 1 year ago

If I may add a little more to the wishlist, having sub-modules / sub-packages would also be something that I would appreciate quite a bit :)

Yeah, I think this will be a nice-to-have. For a long time I've felt like the inability to nest packages is actually a powerful feature that forces the minimal scoping of packages and splitting them into more focused sub packages. However, what I've come to appreciate is how hard it is to develop packages that are inter-dependent (similar to the tidyverse). I think there might be a best of both worlds in here where a package can take a dependency on only a sub-package without taking a dependency on the whole set (Depends: tidyverse::dplyr (>= 1.0.0)).

In that sense, the tidyverse style meta-package becomes a more formalized construct, allowing for the release of a cohort of related packages without the overhead of necessitating all of them to be used together.

There's tons to consider in here that warrants its own issue when we get to that point. If you're passionate about the considerations involved here, I welcome the initiative to get the planning and design started.

sebffischer commented 10 months ago

I would definitely like to work on this, but I would first try to get a better understanding of the code-base! I like the idea of making a "universe" a formalized construct. I am working on a project (mlr3) that is also a collection of dependent R packages and I know some of the troubles related to that, e.g.:

Maybe one could use rust's idea of a workspace for inspiration.

sebffischer commented 10 months ago

To put another item on the agenda: I think the list() datatype in R is currently somewhat overloaded, as it is being used both as a standard (unnamed) list but also as a dictionary (when it has names). Unfortunately it does not ensure that names are unique, and stuff like list(a = 1, a = 2)$a is definitely a source of bugs and something that should not be possible imo.

It might be a good idea, to define this a bit more rigorously and possibly split the list() datatype into a dict() and a (unnamed) list(), what do you think?

sebffischer commented 10 months ago

Also, should partial argument matching still be allowed? Some arguments against it:

Some argument in favour:

Still, I think the amount of typing that is saved (this should actually not really make a big difference when having proper autocompletion) is not worth the disadvantages.