This seems related also. Using match.call to capture ... arguments returns odd results for missing arguments. Compare against another method of capturing ... expressions:
capture_subst <- function(...) eval(substitute(alist(...))) capture_match <- function(...) match.call(expand.dots=FALSE)$... f1 <- function(..., capture) { capture(...) } f1(x=1, q=, capture=capture_subst) f1(x=1, q=, capture=capture_match) On Wed, Jan 23, 2013 at 3:08 PM, Peter Meilstrup <peter.meilst...@gmail.com>wrote: > Hi R-devel. Is the following behavior in g1() and h1() expected? It seems > to make "..." arguments work slightly differently from named arguments. > > #missing() has the property that it looks "up the chain" > #for example, "z" can be missing in f3 even if > #that argument did have a name ("y") in f2 > f1 <- function(x, ...) { > cat("In f1, missing(x) is ", missing(x), "\n") > f2(x, ...) > } > > f2 <- function(y, ...) { > cat("In f2, missing(y) is ", missing(y), "\n") > f3(y, ...) > } > > f3 <- function(z, ...) { > cat("in f3, missing(z) is ", missing(z), "\n") > } > > f1( , 2) #all TRUE > > #does this also work with ... arguments? It seems to lose track. > g1 <- function(...) { > cat("In g1, missing(..1) is ", missing(..1), "\n") > g2(...) > } > > g2 <- function(...) { > cat("In g2, missing(..1) is ", missing(..1), "\n") > g3(...) > } > > g3 <- function(...) { > cat("in g3, missing(..1) is ", missing(..1), "\n") > } > > g1( , 2) #TRUE, TRUE, FALSE ?! > > # we can also elicit this lossiness without looking at the virtual ..n > # symbols: > > h1 <- function(x, ...) { > cat("in h1, missing(x) is ", missing(x), "\n") > h2(x, ...) > } > > hh1 <- function(...) > h2(...) > > h2 <- function(...) > h3(...) > > h3 <- function(z, ...) > cat("in h3, missing(z) is ", missing(z), "\n") > > h3( , 1) #missing in h3 > h2( , 1) #missing in h3 > h1( , 1) #missing in h1 but NOT h3 > hh1( , 1) #also not missing in h3 > [[alternative HTML version deleted]] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel