[Rd] function(x, dim=dim(x)) { str(dim) } => recursive default argument reference
Henrik Bengtsson
hb at stat.berkeley.edu
Thu Jun 4 02:07:02 CEST 2009
Is the following a bug?
Rterm -vanilla
> foo <- function(x, dim=dim(x)) { str(dim) }
> foo(1:2)
Error in str(dim) :
promise already under evaluation: recursive default argument
reference or earlier problems?
> foo(x=1:2)
Error in str(dim) :
promise already under evaluation: recursive default argument
reference or earlier problems?
But, this works:
> foo <- function(x, dim2=dim(x)) { str(dim2) }
> foo(1:2)
NULL
> foo <- function(x, dim=base::dim(x)) { str(dim) }
> foo(1:2)
NULL
> sessionInfo()
R version 2.9.0 Patched (2009-05-28 r48680)
i386-pc-mingw32
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MON
ETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
/Henrik
More information about the R-devel
mailing list