>             // note: The FUN will change the object x itself
>             // hence - it must be clear to use an object we wish to change
> (it will NOT be copied!)

Why do you want to do that?  It's a generally a bad idea to modify R
objects in place.

Here's a simple example showing why C level modification of R object
is particularly dangerous:

library(inline)
foo <- cfunction(c(x = "SEXP"), '{
  INTEGER(x)[0] = 0;
  return R_NilValue;
}')

x <- 1:10
y <- x
foo(x)

# First value is modified as expected
x

# But y is also modified!
y

Hadley

-- 
Chief Scientist, RStudio
http://had.co.nz/
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to