From jeffrey.ryan at lemnica.com  Tue Sep 20 20:12:49 2011
From: jeffrey.ryan at lemnica.com (Jeffrey Ryan)
Date: Tue, 20 Sep 2011 13:12:49 -0500
Subject: [Rd] Is it possible to pass a function argument from R to
 compiled code in C?
In-Reply-To: <1316542046079-3827690.post@n4.nabble.com>
References: <1316539595929-3827563.post@n4.nabble.com>
	<4E78D008.4060800@statistik.tu-dortmund.de>
	<CADwqtCPWD5CXk_TKW10Nsy+GbAML9AAZaMm+J3zSzuhVS5KizA@mail.gmail.com>
	<1316542046079-3827690.post@n4.nabble.com>
Message-ID: <CABDUZc9MNguqRz=L_1D73Gf39cx22OdptJNcbrdpddOQx3tGtg@mail.gmail.com>

You can't call "R" code as if it is C code.  It is R, and requires
that it be evaluated.  How would your C know what to do with an R
pointer...

.Call is more efficient than .C, all the time.  Check this list and
experiment.  That said, you can still call "just C" within the .Call
"R" function, it really is 'just C' in there.

Probably something like a simple example of what you are trying to do
would help the list steer you into the right direction (steer, since
you seem to be missing something in your thinking on this...)

Best,
Jeff

On Tue, Sep 20, 2011 at 1:07 PM, Alireza Mahani
<alireza.s.mahani at gmail.com> wrote:
> OK, thanks. But there are two issues with using ".Call":
>
> 1- I may give up performance if I am literally running R code inside C,
> right? In some ways, wouldn't it defy the purpose of calling a compiled code
> if I end up back in R?
>
> 2- If I use the ".Call" interface, the resulting code will be tailored to R,
> i.e. I will end up having the lengthy code with all the R macros in it. I
> always prefer to use ".C" interface because I can use the exact same piece
> of code inside of a C program, i.e. I can call the same function either from
> R or from C. But with .Call, I am passing R's pointers into the function,
> which obviously I won't be doing when my call comes from inside of C.
>
> Nevertheless, it's good to know that there is at least a sub-optimal
> solution out there (sub-optimal from my perspective, of course!).
>
> -Alireza
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Is-it-possible-to-pass-a-function-argument-from-R-to-compiled-code-in-C-tp3827563p3827690.html
> Sent from the R devel mailing list archive at Nabble.com.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



-- 
Jeffrey Ryan
jeffrey.ryan at lemnica.com

www.lemnica.com
www.esotericR.com



[Rd] Is it possible to pass a function argument from R to compiled code in C?
Jeffrey Ryan