-
-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extending Rcpp after including Rcpp.h #952
Comments
👍 Did you want to add the text @rstub ? |
It's more complicated than adding a line. It needs changes to two vignettes. |
@eddelbuettel Which other vignette would have to be adjusted? The one on modules? Does this possibility to extend Rcpp require the usage of modules? |
I think so. The topic, as I understand your question, really combines 'extending' and 'modules'. I am not so concerned about Sketching out proposed changes here in a few bullet points may be a good start. |
I initially thought that the minimal change would be to only change the code examples to
and
In addition, one could also add something like
to the discussion of these three macros. However, right now I am unable to get a working example for |
Yes, didn't mean to mislead. You need modules. But as the topic is extending I realized we might as well put at least a forward reference in the other vignette. |
Good, that makes it easier to tell a coherent story:
Comments? Preferences in which vignette the main text should go to? |
Why would we need to remove that section? New section sounds good. along with example. Placed in Modules vignette with reference from Extending vignette seems natural. |
Problem with the current section(s) from my point of view is that they do not mention modules at all, which is why I tried to build something like #include <RcppCommon.h>
class Foo {
public:
Foo() = default;
};
RCPP_EXPOSED_CLASS(Foo)
#include <Rcpp.h>
// [[Rcpp::export]]
Foo getFoo() { Foo foo{}; return foo; }
// [[Rcpp::export]]
void handleFoo(Foo foo) { Rcpp::Rcout << "Got a Foo!" << std::endl; }
/***R
foo <- getFoo()
foo
handleFoo(foo)
*/ which does not work. So one would have to add something like "useful for classes exposed as Rcpp modules. See the Rcpp modules vignette for more details" into both sections. |
Can we make this more concrete by referencing which vignette and section you are talking about? |
Extending Rcpp, ends of sections 2.2 and 3.2. |
I learned something new on SO today: https://stackoverflow.com/a/55225006/8416610 Apparently it is possible to extend Rcpp with
RCPP_EXPOSED_CLASS
even afterRcpp.h
has been included. Unsurprisingly @romainfrancois knew about that before: http://romainfrancois.blog.free.fr/index.php?post/2012/10/25/Rcpp-modules-more-flexibleSuggestion: Update the "Extending Rcpp" vignette to
#include <Rcpp.h>
instead of#include RcppCommon.h
(sic) when discussingRCPP_EXPOSED_AS
andRCPP_EXPOSED_WRAP
. One might even draw attention to this quite useful feature.The text was updated successfully, but these errors were encountered: