[Rcpp-devel] Parameter Naming
Darren Cook
darren at dcook.org
Tue Aug 23 15:31:44 CEST 2011
> | | So, my proposal would be to use the same names in the signature that you
> | | intend to use in the C++ code, but with underline appended. I.e.
>
> I was sloppy: compile-time errors. I.e. this:
>
> errorDemo <- cxxfunction(signature(badName="integer"), plugin='Rcpp', body='
> Rcpp::IntegerVector x(otherName);
> return 2*x;
> ')
>
> gives you
> [compile error]
Hello Dirk,
Thanks for the reply. What I meant was "badName" and "x" should be the
same, because using two names for the same thing makes the code harder
to understand and maintain (*). So either this:
goodDemo <- cxxfunction(signature(goodName_="integer"), plugin='Rcpp',
body='
Rcpp::IntegerVector goodName(goodName_);
return 2*goodName;
')
or this:
nearlyAsGoodDemo <- cxxfunction(signature(x_="integer"), plugin='Rcpp',
body='
Rcpp::IntegerVector x(x_);
return 2*goodName;
')
Darren
*: I'm still amazed at how much "throw-away" code, that I was told was
only needed to run for a month, or even for a one-off data import, I end
up still maintaining 3 or 4 years later; I sometimes wonder if my
clients are deliberately lying to me about their intentions ;-)
--
Darren Cook, Software Researcher/Developer
http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)
More information about the Rcpp-devel
mailing list