Skip to content
Back to formatted view

Raw Message

Message-ID: <4E53ABC0.1090106@dcook.org>
Date: 2011-08-23T13:31:44Z
From: Darren Cook
Subject: [Rcpp-devel] Parameter Naming
In-Reply-To: <20045.7221.794988.131613@max.nulle.part>

> | | 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)