Skip to content

too many arguments in foreign function call

4 messages · Warnes, Gregory R, Brian Ripley, Duncan Murdoch +1 more

#
Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
> Gregory R. Warnes <gregory_r_warnes at groton.pfizer.com> wrote 
  > >
  > >I would like to create an R package that will depend on 
  > the ability to use
  > >more than 65 parameters.  Would it be reasonable to expect 
  > this patch (or
  > >something equivalent) to be part of , say R > 1.3.1 ?
  > 
  > People are slow to upgrade, so you might be better off in the short
  > run to somehow reduce the number of parameters below 65.  
  > For example,
  > write a wrapper function that groups a number of scalar parameters
  > into one vector.

Actually, the whole point of the patch was to get out of this.  I want to
keep the code as close to what was written by the original author and as
simple as possible...

-Greg


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Mon, 16 Jul 2001, Warnes, Gregory R wrote:

            
Sorry, but I don't see that.  You want to write the wrapper in R?  Why is
it not as simple to write it in C?  I really don't see the need to remove
the limitation in R (or even to have it as high as 65) since R now has
.External() which allows an unlimited list of arguments to be passed to C
code.  I can't believe that the natural R representation is 85 separate
objects, so the natural way looks like a C wrapper translating between R
objects and Fortran pointers.  You can even copy selectively.

The argument is that new code should probably be using .Call (if S
compatibility is relevant) or .External rather than .C, at least provided
that a C wrapper is feasible.  Those interfaces seem very much under-used.
(Including by me, for S3-compatibility reasons.)
#
On Mon, 16 Jul 2001 19:23:52 +0100 (GMT Daylight Time), you wrote in
message <Pine.WNT.4.31.0107161916001.1056-100000 at tern.stats>:
The difficulty with using .External is that it only works with C, not
with other languages, because you need the R header definitions.  I
think there is a fairly large group of programmers like myself who
aren't very comfortable programming in C.  The .C interface isn't tied
to the R header files the way .External is, so it's not too hard to
call other languages with it.  I use it with Delphi and Kylix, for
instance.

It's a nice quirk that ".C" is the interface to use for general
external code, and ".External" for C code.

Duncan Murdoch
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Duncan Murdoch <murdoch at stats.uwo.ca> writes:
That's a coincidence, highly dependent on other languages abiding the
C calling conventions (and arguably, .External is really interfacing
to a Scheme-like runtime system rather than general C code...)

It's like Brian says: If you can figure out how to call the other
language from C, then it really shouldn't be any trouble to setup a
wrapper using either of the interfaces .C, .Call, and .External. And
given that you usually need "onionskin" routines to convert pointer
arguments for call-by-value usage, the extra work of zipping a bunch
of scalar arguments out of a vector does seem rather minute.