Skip to content

too many arguments in foreign function call

1 message · John Chambers

#
Prof Brian D Ripley wrote:
The limitation to 65 arguments (or at any rate some fixed number) is
imposed by pretty fundamental limitations of C.  It applies to .External
and .Call as well as to .C, and any S language interface will have such
a limit unless it goes around the C calling mechanism (which in turn
would likely be devastating for portability).

It's understandable to want to create as little new C code as possible,
but since there has to be a limit, at some point we're saying "More than
N arguments to a subroutine are too confusing.  Simplify it before you
expose the interface to users."  65 seems a plausible value for N to me.

The example Greg describes with a bunch of scratch arrays is, in my
experience, usually best handled by a .Call to a C wrapper that uses C
macros from Appendix A of the green book to allocate the scratch space
(NEW_NUMERIC and NUMERIC_POINTER, for example).  That is usually only
marginally more work than writing the wrapper in R, is a good deal more
efficient, and hides the grosser ugliness from the end user better.

John