Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make use of ... consistent and documentable #17

Open
gadenbuie opened this issue Sep 1, 2018 · 0 comments
Open

Make use of ... consistent and documentable #17

gadenbuie opened this issue Sep 1, 2018 · 0 comments
Milestone

Comments

@gadenbuie
Copy link
Owner

We need to ensure that arguments passed through ... are documentable (i.e. are inherited from another function) and that their scope is relatively limited.

Currently, nearly every function takes ... which means that we don't have issues with extra arguments being passed to functions that don't take them.

This short reprex demonstrates the issue with removing ... from existing functions.

f <- function(x = "a", ...) paste(x)

g <- function(y = "b", ...) paste(y)

h <- function(z, ...) paste(z, g(...), f(...))

# Doesn't have ... to capture unused arguments
f2 <- function(x = "a") paste(x)

h2 <- function(z, ...) paste(z, g(...), f2(...))

h("c", y = "e")
#> [1] "c e a"
h2("c", y = "e")
#> Error in f2(...): unused argument (y = "e")

In the above example, we would need to add x as a parameter to h2() or do some work to separate the arguments in the .... In the end, though, the effort will be worth it because documentation will be much clearer and the user will be able to figure out from autocompletion, etc, what parameters get passed to which functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant