>From an example in >http://www.uni-muenster.de/ZIV.BennoSueselbeck/s-html/helpfiles/nargs.html , >number of arguments in '...' can be obtained by (function(...)nargs())(...) .
I now realize that sys.call() doesn't expand '...' when the function is called with '...'. It just returns the call as is. If 'stopifnot' uses sys.call() instead of match.call() , the following example behaves improperly: g <- function(...) stopifnot(...) g(TRUE, FALSE) -------------------------------------------- On Thu, 18/5/17, Martin Maechler <maech...@stat.math.ethz.ch> wrote: Subject: Re: [Rd] stopifnot() does not stop at first non-TRUE argument Cc: r-devel@r-project.org Date: Thursday, 18 May, 2017, 3:03 PM >>>>> Suharto Anggono Suharto Anggono via R-devel <r-devel at r-project.org> >>>>> on Tue, 16 May 2017 16:37:45 +0000 writes: > switch(i, ...) > extracts 'i'-th argument in '...'. It is like > eval(as.name(paste0("..", i))) . Yes, that's neat. It is only almost the same: in the case of illegal 'i' the switch() version returns invisible(NULL) whereas the version we'd want should signal an error, typically the same error message as > t2 <- function(...) ..2 > t2(1) Error in t2(1) (from #1) : the ... list does not contain 2 elements > > Just mentioning other things: > - For 'n', > n <- nargs() > can be used. I know .. [in this case, where '...' is the only formal argument of the function] > - sys.call() can be used in place of match.call() . Hmm... in many cases, yes.... notably, as we do *not* want the argument names here, I think you are right. ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel