>>> ...The job of the thin R wrapper function is to sanity check >>> and/or coerce the vars to the correct type before they are past >>> to the inline'd function to avoid the segfault. >> >> Why do you do this in R, instead of in the C++ function? (The >> advantage of doing it in the C++ function is that there is no way >> to accidentally skip the validation.) > > Simply because it's less tedious to write in R, so I guess I'm a bit > lazy that way. > > I'm a bit more aggressive with my naming though, ie. if I want the > function to be called `func`, the R function `func` is the function > that does the initial type checking/coersion which then calls down to > the inlined Rcpp function, which would would be something like > `.func.cpp`, which is named thusly so that I make sure I never > "forget" that I shouldn't be calling that directly ...
Thanks for the reply Steve. Perhaps ".func.no.validation" makes it really hard to forget in 6 months time :-) Another advantage of validation in a wrapper (whether that wrapper is done in R or C++) is you can deliberately skip over it when you know your parameters are valid (e.g. because the parent function has already checked them). A common technique for optimization. Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel