[Rd] arguments to .Call(), .External should be read-only?

Greg Minshall minshall at acm.org
Tue Jul 8 16:05:03 CEST 2014

hi.  if i'm reading correctly, "Writing R Extensions" appears to be
inconsistent on the question of whether the arguments passed to a
routine called via .Call() or .External() should considered read-only.
section 5.2, "Interface functions .C and .Fortran", says
However, when character vectors are used other than in a read-only way,
the .Call interface is much to be preferred.

which sort of implies (if one reads optimistically) that using .Call()
(by extension, again optimistically, .External()) one could treat
*character* vectors (and, again, optimistically, numeric, etc., vectors)
in a non-read-only way.

on the other (pessimistic) hand, section 5.9, "Handling R objects in C",
Neither .Call nor .External copy their arguments: you should treat
arguments you receive through these interfaces as read-only.

for an application, i'd like to consider these writable.  assuming
sufficient warnings in the documentation, etc., is that permissable?

cheers, Greg Minshall

More information about the R-devel mailing list