[R] storage.mode and argument duplication

Paul Gilbert pgilbert at bank-banque-canada.ca
Wed Jan 21 22:34:17 CET 2004


I have a function which passes an element of a fairly large list to a 
fortran call. In a function, when I use storage.mode on an element of a 
list that is in the function argument, does this force the whole list to 
be duplicated? More specifically, which of these should result in less 
extra copying?

foo <- function(x)
   {storage.mode(x$one) <- "double"
    .Fortran("foo", x$one, result=as.double(rep(0,3)))["result"]
   }

or

foo <- function(x)
   {.Fortran("foo", as.double(x$one),
              result=as.double(rep(0,3)))["result"]
   }

Thanks,
Paul Gilbert




More information about the R-help mailing list