It seems like there is an unnecessary extra copy here, unless of course
the array in the R object cannot be the C array (but your example of
messing up things in the parent environment suggests it can be). If
Well, in current R internals there is no simple way to create an R array
out of data held in a C array. (It can be done, but is messy AFAIK.)
Also, with DUP=TRUE, you need protection. The C routine might have cached
that address and use it next time it was called, thereby working with part
of the `newly created R object'.
ok, I think I'll avoid this for now. On the wish list: it would be nice to have a
call which distinguished items to return and only built an R object of those rather
than the complete list of arguments in the call (for me with .Fortran especially).
Why are you using .C not .Call anyway? These things are much easier to
control with .Call.
Actually, I am using .Fortran, I just happened to grab Thomas example. I understand
the documentation to mean that .Call and .External are only alternatives to .C and
not to .Fortran. If I'm wrong on that please let me know.