[Rd] dealing with empty actual arguments matched by '...' formals

Duncan Murdoch murdoch at math.aau.dk
Sat Apr 16 10:59:38 CEST 2005


Tony Plate wrote:
> I'm trying to write some functions to deal with empty actual arguments 
> that are picked up by '...' formals.  Such actual arguments are common 
> (and very useful) in calls to subsetting functions, e.g., x[1:2,].  It 
> seems that R and S-PLUS treat these arguments differently: in S-PLUS 
> list(...) will return a list containing just the non-empty arguments, 
> whereas in R list(...) stops with an error:
> 
>  > # In R:
>  > f <- function(x, ...) list(...)
>  > f(1,2)
> [[1]]
> [1] 2
>  > f(1,2,)
> Error in f(1, 2, ) : argument is missing, with no default
>  >
> 
> So it seems that quite different methods must be used in S-PLUS and R to 
> detect and process the arguments of a function that can have empty 
> arguments matched to '...'.

Can you give an example where it's useful to do this, i.e. to have a 
call like f(1,2,)?  I've never used that construction as far as I can 
recall.

Duncan Murdoch



More information about the R-devel mailing list