kevinushey / dotty

Destructuring assignments in R with the `.` object.
https://kevinushey.github.io/dotty/
Other
42 stars 0 forks source link

Mixing named and unnamed unpacking #3

Closed DavisVaughan closed 2 months ago

DavisVaughan commented 2 months ago
library(dotty)

.[apple = x, banana] <- list(w = 1, x = 2, y = 3, z = 4)
apple
banana

Both of these return 2, is that right?

In general getting this "right" is probably quite hard.

Maybe it should be "if any are named, all must be named"?

kevinushey commented 2 months ago

Maybe it should be "if any are named, all must be named"?

I think that is probably the simplest way forward to reduce confusion. If not, then I think the right approach would be to implement argument matching in a way similar to R.

DavisVaughan commented 2 months ago

I vote for simplest and strictest now and if people revolt you can always relax it without breaking anything