Skip to content
Prev 44620 / 63421 Next

Changing arguments inside .Call. Wise to encourage "const" on all arguments?

On Dec 10, 2012, at 2:05 PM, Simon Urbanek wrote:

            
Martin Morgan pointed out that this example is a bad one -- which is true. The common idiom that is safe is

SEXP foo(SEXP bar) {
...
return bar;
}

However, the last() example above is bad, because returning the element directly is a bad idea -- the conservative approach would be to use duplicate(), the more efficient one would be to bump up NAMED. Sorry, my bad. I guess I was rather strengthening Paul's point to duplicate() when in doubt even if it's less efficient :).

Cheers,
Simon