Hi Darren, On Thu, Jan 5, 2012 at 2:05 AM, Darren Cook <dar...@dcook.org> wrote: > Steve Lianoglou wrote: >> When I use inline for anything semi-permanent (the last step before >> turning it into a package, let's say), I typically have a thin R >> wrapper function that calls down to my inline function and I never >> call the inline function directly anywhere else. 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. > (I've pasted in below an example, from you, from another thread to show > what you mean.) > > 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 ... still, if my 6-month-later self doesn't figure out that calling `.func.cpp` directly is verboten, then it's my fault. I don't disagree, though, doing the argument checking on the C-side of the code is more robust. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact _______________________________________________ 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