Skip to content
Back to formatted view

Raw Message

Message-ID: <4260D3FA.4030905@math.aau.dk>
Date: 2005-04-16T10:59:46Z
From: Duncan Murdoch
Subject: dealing with empty actual arguments matched by '...' formals
In-Reply-To: <425FDE7C.1080709@blackmesacapital.com>

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