From gregor.gorjanc at bfro.uni-lj.si  Thu Mar  1 11:39:24 2007
From: gregor.gorjanc at bfro.uni-lj.si (Gregor Gorjanc)
Date: Thu, 01 Mar 2007 11:39:24 +0100
Subject: [Rd] Registration of native routines
Message-ID: <45E6AD5C.2030508@bfro.uni-lj.si>

Dear R developers,

I am working on registration of native C and FORTRAN routines and have
encountered "inconsistencies" about this issue. I am referring to
"Registering native routines" section of R-ext manual.

*(DL_FUNC), &F77_SUB, &F77_SYMBOL

On line 5108 of R-ext.texi the array for method myCall is defined as

  {"myCall", &myCall, 3},

but looking at examples in src/library/stats/src/init.c I notice
addition of (DL_FUNC) i.e. upper definition would be

  {"myCall", (DL_FUNC) &myCall, 3},

This probably shows my poor knowledge of C, but what is the role of
(DL_FUNC)? Looking around the code I notice that DL_FUNC is used also in
other places. IMHO I would suggest that (DL_FUNC) is also "mentioned" in
the manual.

Additionally, what is the role of &F77_SUB() in registration of FORTRAN
subroutines i.e. the following line is one example from
src/library/stats/src/init.c.

    {"lowesw", (DL_FUNC) &F77_SUB(lowesw), 4}

src/main/registration.c for example uses &F77_SYMBOL() instead of
&F77_SUB(). Poking around the source I see that this is related to _. I
would again suggest to add this to the manual.

*Type and style field

For .C() and .Fortran() manual says that registration array can also
hold type and style fields. It is shown how type field should look like,
but nothing usable is said about style except

<manualSays>Typically, one omits this information in the registration
data.</manualSays>

Why would one omit this if

<manualSays>The purpose is to allow @R{} to transfer values more
efficiently across the R-C/FORTRAN interface by avoiding copying values
when it is not necessary.</manualSays>?

Thank you!

Gregor



[Rd] Registration of native routines
Gregor Gorjanc