Skip to content
Prev 56593 / 63421 Next

Use of C++ in Packages

tl;dr: we need better C++ tools and documentation. 

We collectively know more now with the rise of tools like rchk and improved documentation such as Tomas?s post. That?s a start, but it appears that there still is a lot of knowledge that would deserve to be promoted to actual documentation of best practices. 

I think it is important to not equate C++ as a language, and Rcpp. 

Also, C++ is not just RAII. 

RAII is an important part of how Rcpp was conceived for sure, but it?s not the only thing C++ can bring as a language. Templates, lambdas, the stl are examples of things that can be used for expressiveness when just accessing data without interfering with R, calling R api functions ... 

It would be nice that the usual ? you should do that only if you know what you?re doing ? be transformed to precise documentation, and maybe become part of some better tool. If precautions have to be taken before calling such and such functions: that?s ok. What are they ? Can we embed that in some tool.

 It is easy enough to enscope code that uses potentially jumpy code into a c++ lambda. This could be together with recommendations such as the body of the lambda shall only use POC data structures. 

This is similar to precautions you?d take when writing concurrent code. 

Romain