Jeff,

On Aug 17, 2009, at 10:23 , Jeffrey J. Hallman wrote:

One hassle I could do without is the necessity of writing C wrapper functions
like this:

void fameInit(int *status){
 cfmini(status);
 return;
}

when I want to call a library function (cfmini, in this case) that takes an int argument. The .C interface only lets me pass a pointer to an int, rather
than the int itself.

Is there any chanch that .C could be enhanced to allow passing arguments by value to the compiled code?

IMHO close to 0, because there is not such a thing as "scalar int" in R. All objects in R are arrays (in C speak), so in all three:
foo(integer(0)), foo(1L), foo(1:10)
the argument is of the same type: integer vector (analogously C type int[]). In fact .C should preferably not be used for wrappers like the one you suggested, because it's more prone to errors and much less flexible than .Call which gives you all you want including the control over duplication and the length of the supplied arguments.

(There are some packages that can generate wrappers from function arguments or header files - maybe the authors can comments on that if they wish).

Cheers,
Simon

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to