[Rcpp-devel] ListOf -- update
romain at r-enthusiasts.com
Tue Oct 29 08:29:19 CET 2013
I'll review this when I get a chance. If we include this in Rcpp, it
will have to be split into at least two files. Everything that uses wrap
or as has to go in meat.
Le 29/10/2013 05:02, Kevin Ushey a écrit :
> Hi guys,
> With some encouragement from Romain, I took a shot at implementing the
> ListOf<T> class. For now, everything's just in one big .cpp file here
> (later I can factor it out to .h and .cpp files). But please take a
> look here:
> I took Romain's suggestions from before and 1) have ListOf<T>
> inheriting from List directly, and 2) proxified operator so we can
> distinguish read / write (merci, Scott Meyers, for More Effective
> C++). Ultimately, most of it is boilerplate used so that the proxy is
> handled correctly.
> The class isn't too complicated, but it is surprisingly functional
> since it can leverage everything already available in Rcpp. It works
> well with the sugar functions and it can be handled by Rcpp attributes
> as-is as well. There are a couple of demonstrative examples at the
> bottom (to be written as a more formal test suite later).
> I would welcome any comments; I'm fairly inexperienced as a C++
> programmer so I'm sure some things might be wrong.
You're on the right track.
> Things I know could be better and would appreciate some advice on:
> 1) Use Rcpp's traits system rather than TYPEOF for mapping template
> types to strings (ie. in validate), (eg: going from Rcpp classes to
> internal SEXP types; more generally, how can I navigate the traits
> 2) Extend lapply, sapply to infer types for applied templated
> functions from ListOf<T> classes, so for e.g. a ListOf<NumericVector>
> x and a template function add_1, we could just write
> lapply(x, add_1);
> rather than
> lapply(x, add_1<NumericVector>);
Professional R Enthusiast
+33(0) 6 28 91 30 30
More information about the Rcpp-devel