r-lib / rlang

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

Tidyeval version of dots_values() #171

Closed egnha closed 7 years ago

egnha commented 7 years ago

It would be nice to have a tidyeval version of dots_values(), say dots_values_tidy():

dots_values_tidy <- function(..., .ignore_empty = c("trailing", "none", "all")) {
  dots <- dots_capture(..., `__quosured` = FALSE)
  dots <- dots_clean_empty(dots, function(x) is_missing(x$expr), .ignore_empty)
  if (is_null(dots)) {
    dots <- list(...)
    set_names(dots, names2(dots))
  } else {
    map(dots, function(dot) eval_tidy(dot$expr, env = dot$env))
  }
}

This is simply dots_values() copied verbatim, with eval_bare() replaced by eval_tidy() in the else-clause.

@lionel- Is this reasonable? (Or does rlang already provide this functionality?)

Then, for example, it would be possible for the user to implement a tidyeval version of dots_list() and dots_splice().

egnha commented 7 years ago

eval_tidy(dots_values(...)) already does this.