r-lib / usethis

Set up commonly used 📦 components
https://usethis.r-lib.org/
Other
854 stars 284 forks source link

Re-export := with use_tidy_eval #595

Closed jonthegeek closed 5 years ago

jonthegeek commented 5 years ago

:= (the tidyeval assignment operator, which I pronounce "digested is") is often as useful for tidyeval as the functions exported by the file generated via usethis::use_tidyeval(). It would be helpful if it were also re-exported.

hadley commented 5 years ago

But it doesn't actually do anything?

jonthegeek commented 5 years ago

Don't you need it when there's tidyeval on the LHS of a parameter assignment? When I do that, cran checks complain about := until/unless I at least import.

batpigandme commented 5 years ago

This is still the method we have in the tidyeval cookbook, and programming with dplyr:

library(rlang)
name <- "the real name"
c(name = NA)

rlang::qq_show(c(!!name := NA))
rlang::qq_show(c(!!name = NA))
#> Error: <text>:6:25: unexpected '='
#> 5: rlang::qq_show(c(!!name := NA))
#> 6: rlang::qq_show(c(!!name =
#>                            ^

Created on 2019-01-23 by the reprex package (v0.2.1.9000)

hadley commented 5 years ago

Yeah, it's just a syntactic operation so the := function is never actually called (IIRC). But if R CMD check has a problem with it, we should include. @jonthegeek do you want to do a PR?

jonthegeek commented 5 years ago

Sure, I can probably knock this out tonight.

jennybc commented 5 years ago

Ironically I am getting this exact NOTE in a usethis branch, due to my use of :=.

jennybc commented 5 years ago

I think we need to think separately about the need for @importFrom rlang := vs. the need to re-export it. cc @lionel-

lionel- commented 5 years ago

Reexporting it in our packages will give a useful error message when := is used in a wrong context, so that seems helpful.