# While tidy_capture() only work for the most direct calls, that's
# not the case for tidy_dots(). Dots are forwarded all the way to
# tidy_dots() and can be captured across multiple layers of calls:
fn <- function(...) tidy_dots(y = a + b, ...)
fn(z = a + b)
# However if you pass a named argument in dots, only the expression
# at the innermost call site is captured:
fn <- function(...) tidy_dots(x = x)
fn(x = a + b)
# Dots can be spliced in:
args <- list(x = 1:3, y = ~var)
tidy_dots(!!! args, z = 10L)
# Raw expressions are turned to formulas:
args <- alist(x = foo, y = bar)
tidy_dots(!!! args)
# Definitions are treated similarly to named arguments:
tidy_dots(x := expr, y = expr)
# However, the LHS of definitions can be unquoted. The return value
# must be a symbol or a string:
var <- "foo"
tidy_dots(!!var := expr)
# If you need the full LHS expression, use tidy_defs():
dots <- tidy_defs(var = foo(baz) := bar(baz))
dots$defs
Run the code above in your browser using DataLab