r-devel / r-project-sprint-2023

Material for the R project sprint
https://contributor.r-project.org/r-project-sprint-2023/
17 stars 3 forks source link

Other places where chkDots() is needed? #79

Open hturner opened 1 year ago

hturner commented 1 year ago

Following up from @bastistician's talk in the kick-off session where he discussed his recent change to subset.data.frame() which used chkDots() to avoid problems with additional arguments being ignored.

I wonder if there are other functions using ... where chkDots() should be added at the beginning. Should this function be called for any function with ...? Or is subset.data.frame() a special case because of the more likely confusion between an intended subsetting condition (e.g. gear == 4) and an accidental argument setting (gear = 4)

bastistician commented 1 year ago

Thank you for raising this. I think this needs to be decided on a case-by-case basis. Adding chkDots(...) essentially precludes (or at least makes it more cumbersome) to have that method called via the NextMethod() mechanism, because extra arguments from other methods are no longer silently ignored. So one has to weigh the two competing goals. Now, subset.data.frame is quiet special in that its help clearly says that "This is a convenience function intended for use interactively", so there is no strong NextMethod() case. I did wonder, however, whether chkDots() would be a good candidate for producing a classed warning (#62) such that it can be catched specifically in the event it is expected.