From murdoch at math.aau.dk  Sat Apr 16 10:59:38 2005
From: murdoch at math.aau.dk (Duncan Murdoch)
Date: Sat Apr 16 10:59:46 2005
Subject: [Rd] dealing with empty actual arguments matched by '...' formals
In-Reply-To: <425FDE7C.1080709@blackmesacapital.com>
References: <425FDE7C.1080709@blackmesacapital.com>
Message-ID: <4260D3FA.4030905@math.aau.dk>

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


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