[Rcpp-devel] Function speed - assignment versus pointer passing?

Christian Gunning xian at unm.edu
Wed Sep 1 09:46:51 CEST 2010

Is there a good rule of thumb for when to write a function that
returns an object (to be assigned to a variable) versus passing the
object pointer to the function to be modified in place?

I'm more familiar with R's function programming style, which i've seen
in Rcpp documents and list examples:

b = fx(a);

whereas traditional C forbids returning vectors and enforces modify-in-place:

fx(a, &b);

Is there compiler magic that makes these two cases equivalent, or
should 2 to be preferred for heavy lifting?

Christian Gunning
University of New Mexico

More information about the Rcpp-devel mailing list