[Rd] vapply definition question

Mick Jordan mick.jordan at oracle.com
Wed Dec 17 05:20:14 CET 2014


vapply <- function(X, FUN, FUN.VALUE, ...,  USE.NAMES = TRUE)
{
     FUN <- match.fun(FUN)
     if(!is.vector(X) || is.object(X)) X <- as.list(X)
     .Internal(vapply(X, FUN, FUN.VALUE, USE.NAMES))
}

This is an implementor question. Basically, what happened to the '...' 
args in the call to the .Internal? cf lapply:, where the ... is passed.

lapply <- function (X, FUN, ...)
{
     FUN <- match.fun(FUN)
     ## internal code handles all vector types, including expressions
     ## However, it would be OK to have attributes which is.vector
     ## disallows.
     if(!is.vector(X) || is.object(X)) X <- as.list(X)
     ##TODO
     ## Note ... is not passed down.  Rather the internal code
     ## evaluates FUN(X[i], ...) in the frame of this function
     .Internal(lapply(X, FUN, ...))
}

Now both of these functions work when extra arguments are passed, so 
evidently the implementation can function whether the .Internal "call" 
contains the ... or not. I found other cases, notably in S3 generic 
methods where the ... is not passed down.

So, essentially, my question is whether the vapply code "should" be 
changed or whether a .Internal implementation should always assume an 
implicit ... regardless of the code, if the semantics requires it.

Thanks
Mick



More information about the R-devel mailing list