[Rcpp-devel] Idiom for accessing scalars

Dirk Eddelbuettel edd at debian.org
Fri Jan 6 20:12:21 CET 2012


On 6 January 2012 at 12:59, Douglas Bates wrote:
| On Fri, Jan 6, 2012 at 12:39 PM, John Chambers <jmc at stat.stanford.edu> wrote:
| > The "Rf_" part of the API in particular is ugly and somewhat of an add-on
| > forced in a few examples by the use of some common names in the macro files.
| 
| But, as it stands, that is a requirement when using Rcpp.

Where?  I can think of one propagated use, which is at the bottom of the
try/catch structure where we use ::Rf_error.  But the commonly used macros
hide it, and we could/should obviously wrap this.

Otherwise, and especially since the 'Rcpp sugar' initiative took off, I don't
really touch any ::Rf_* myself anymore.  Inside the Rcpp code base, sure. But
not really in user-facing stuff and Rcpp applications.
 
| I think of the Rf_ part as more due to the fact that C doesn't have a
| concept of namespaces so anything in the R API is at the top level
| namespace leading to some conflicts.

Agreed.  But speaking stylistically, for the same reason that we prefer C++
versions of C header files (eg cstdint over stdint.h, cstdio over stdio.h,
...) I am with John on the preference for C++ idioms when given a choice.

Dirk

-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx


More information about the Rcpp-devel mailing list