sourceCpp code argument

74 views
Skip to first unread message

Gabor Grothendieck

unread,
May 10, 2014, 10:37:19 AM5/10/14
to r-an...@googlegroups.com
Could you add the code= argument that is in Rcpp:;sourceCpp to attributes::sourceCpp.  

I find it useful for creating self-contained single file runs.

Romain Francois

unread,
May 10, 2014, 5:55:25 PM5/10/14
to Gabor Grothendieck, r-an...@googlegroups.com
That is the perfect case for creating an account on github and start creating issues. Even if you just use the account for that it makes sense. 

This mailing list is more meant for general questions about R/C++. This really is a feature request. Of course I can go ahead and translate this email into a feature request on github, but I can also forget to do it. 

Romain

Le 10 mai 2014 à 16:37, Gabor Grothendieck <ggroth...@gmail.com> a écrit :

Could you add the code= argument that is in Rcpp:;sourceCpp to attributes::sourceCpp.  

I find it useful for creating self-contained single file runs.

--
You received this message because you are subscribed to the Google Groups "R and C++" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-and-cpp+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Romain Francois

unread,
May 11, 2014, 4:36:41 AM5/11/14
to Gabor Grothendieck, r-an...@googlegroups.com
I have opened this issue, as I do agree with you that it is a nice feature. I'm currently doing some refactoring work on Rcpp11, so I might not get to this for a few days. Perhaps Kevin will get there first.

It would be simple enough to write anyway, so perhaps someone will open a pull request for it.

Romain

Le 10 mai 2014 à 16:37, Gabor Grothendieck <ggroth...@gmail.com> a écrit :

Kevin Ushey

unread,
May 11, 2014, 2:16:23 PM5/11/14
to r-an...@googlegroups.com, Gabor Grothendieck, rom...@r-enthusiasts.com
Hi Gabor,

I've implemented this in attributes now -- can you try getting the latest version from GitHub and giving it a whirl?

Thanks,
Kevin

Gabor Grothendieck

unread,
May 11, 2014, 4:10:22 PM5/11/14
to Kevin Ushey, r-an...@googlegroups.com, Romain Francois
Thanks! I just re-installed Rcpp11 and atributes and then tried the
following example and it worked:


code <- '
#include <Rcpp.h>
#include <boost/range/irange.hpp>

// [[Rcpp::depends(BH)]]

// [[Rcpp::export]]
int useCpp11() {
auto sum = 0;
for(const auto i : boost::irange(0,4)) { sum += i; }
return sum;
}
'

library(Rcpp11)
library(attributes)
sourceCpp(code = code)
useCpp11()
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

Kevin Ushey

unread,
May 11, 2014, 4:12:25 PM5/11/14
to Gabor Grothendieck, r-an...@googlegroups.com, Romain Francois
Very cool :) thanks for confirming!
Reply all
Reply to author
Forward
0 new messages