[Rd] match.call problem (PR#813)

p.dalgaard@biostat.ku.dk p.dalgaard@biostat.ku.dk
Fri, 12 Jan 2001 17:46:06 +0100 (MET)


Previously reported by Martin as a plot.formula issue, but I believe
it boils down to this:

> f <- function(x,...)match.call(expand.dots=FALSE)
> g <- function(x,y=2,...)f(x,y=y,...)
> g(1)
f(x = x, ... = list(y = y, ...))
> g(1,b=2) 
f(x = x, ... = list(y = y, b = 2))
> g(1,y=2)
f(x = x, ... = list(y = y, ...))

Notice that ... appears if all actual arguments to g are matched in
the call to f. This is the *name* "..." as in as.name("..."). I would
have expected just ... = list(y = y) in those cases.

Simpler

> f <- function(x,...)match.call(expand.dots=FALSE)
> g <- function(x,...)f(x,...)
> g(1)
f(x = x, ... = list(...))
> g(1,2)
f(x = x, ... = list(..1 = 2))
> g(1,a=2)
f(x = x, ... = list(a = 2))

or yet again simpler

> f <- function(...)match.call(expand.dots=FALSE)
> g <- function(...)f(...)
> g(1)
f(... = list(..1 = 1))
> g()
f(... = list(...))
> f()
f()


For comparison, Splus 3.4 has this kind of stuff:

> f <- function(...)match.call(expand.dots=FALSE)
> g <- function(...)f(...)
> g()
f(... = list())
> f()
f(... = list())
> g(1)
f(... = list(1))
> g(a=1)  
f(... = list(a = 1))

I don't see why we don't do the same (although given differences in
lazy evaluation, there might be a point to it), but just getting rid
of the ... in the lists would help quite a bit.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._