Closed rpruim closed 7 years ago
Hmm, I don't think I would like that. dplyr
is still R code.
I don't see how this would violate being R code. Is it substantially different from
x[2, ]
which is standard R usage?
Of course, you would be free not to use this feature.
well x[2, ]
is not the same as x[2]
True. But it is an example where an empty argument doesn't cause things to break and is useful. So I think there is no prohibition on writing functions that allow empty arguments.
I have often wished that c() and list() had this behavior. It would make code maintenance easier.
I see this as a small violation of R's usual rules, in the service of making a common error less common. I don't see any major downsides (except that people might come to expect this in all R functions).
I remember when this wasn't an error in R, and I still miss those days :(
In that case, we are probably looking at a change in lazy_dots
or perhaps how we use it here.
@lionel- can you take this on as part of tidyeval conversion?
It would be nice to allow a trailing comma in commands like the example below. That would make it easier to rearrange the order or to comment out lines without needing to figure out whether the commas need adjusting.
I'm imaging a function that could be called at the top of a function definition that would gobble this empty argument. Or perhaps a wrapper function a la
Vectorize()
that could be used to convert any function into a function with this behavior. Seems like this could be useful for many functions both withindplyr
and elsewhere.