D-Link with R/MATLAB/Julia/SQL

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Tue Dec 10 09:08:34 PST 2013


On 09/12/13 21:22, bachmeier wrote:
> I will write something up as soon as I can, but it might be a while before that
> happens. I will also share my code for the .Call interface. Hopefully I will get
> feedback from someone more knowledgeable about D.
>
> I'll leave DConf to the experts. I'm an economist who taught himself to program.

It's always worth remembering that while there are probably plenty of people 
here who are more expert in D, you may be much rarer in having practical 
experience of R and in using it effectively in combination with D.

The other thing to remember is that it's valuable to highlight diverse use-cases 
for the language.  Don't be shy about things like this; simply publicizing the 
challenges of what you're doing is valuable in itself.

So, don't assume that DConf would not want to hear about your work :-)

> Your colleague might well be right, but I'm not familiar with that issue. In the
> other direction (R to C) you want to copy the data before mutating. Suppose you
> have
>
> x <- c(1,2,3)
> y <- x
> .Call("foo", y)
>
> R does a lazy copy of x into y, such that y is a pointer to x until the copy is
> actually needed. In this example, when you pass y from R to C, all you're
> passing is a pointer to the struct (SEXP). On the C side, you can do anything
> you want with that pointer, and it will modify both y and x unless you make a
> copy of y.
>
> You can create an SEXP on the C side and pass it into R, but that's a bit clumsy
> so I avoid it. Whether I'm embedding R in C/C++/D or vice versa I do the
> allocation in R. Moving data between R and D is nothing more than passing a
> pointer around.

Ahh, OK.  Good to know for future reference -- thank you!



More information about the Digitalmars-d mailing list