r-lib / rlang

Low-level API for programming with R
https://rlang.r-lib.org
Other
508 stars 138 forks source link

dot_names #415

Open hadley opened 6 years ago

hadley commented 6 years ago
dot_names(a = 1, b = 2, 3)
#> [1] "a" "b" NA

It's sometimes useful to capture the names of dotted arguments without evaluating them for generating error messages.

Related to dots_n()

lionel- commented 6 years ago

Would it make sense for dots_names() and dots_n() to have an expand argument? If TRUE, it would expand !!! to give the right answer when tidy dots are enabled. Should probably default to FALSE because this can have side effects or be costly.

Maybe we can also check for !!! when expand is FALSE and either return NA or throw an error.

hadley commented 6 years ago

Or we could choose to make them blind to tidy dots. I think dots_n() and dots_name() are mostly used for generating error messages. It's not clear that they need to support tidy dots (or we could at least wait to implement until we have a concrete need)

daikonradish commented 6 years ago

hi! i'm writing a package that aims to help malaria metaanalysis researchers by allowing them to build tables declaratively, e.g.

MasterMalariaTableSchema <- BaseSchema(
    ID=character,
    temperature=numeric,
    parasitaemia=numeric,
    recrudescent=logical)

I was really struggling with ..., but googling around and finding this page led to learning about rlang::exprs, which I think is precisely what I need. Thanks <3