[Rcpp-devel] generalizing make_list

Dirk Eddelbuettel edd at debian.org
Thu Mar 18 13:37:41 CET 2010


On 18 March 2010 at 13:16, Romain Francois wrote:
| Le 18/03/10 12:55, Dirk Eddelbuettel a écrit :
| > | I am very happy about the make_list templates, but it only handles
| > | lists, and the next best thing would be having something that would
| > | handle all sorts of vectors.
| >
| > My first question would be "Why exactly?"  We have a very clear use case for
| > lists as we need to ship results back to the calling R process.  But why do
| > we need that ?
| 
| named vectors are as common in R as named lists.
| 
| RcppArmadillo has an example of creating a named integer vector:
| 
| IntegerVector version(3);
| version = av.major, av.minor, av.patch ;
| CharacterVector names(3);
| names = "major", "minor", "patch" ;
| version.names() = names ;

And even there it's purely cosmetic because the equivalent functionally is
just before (which you don't show) where we map this to an int as

    return Rcpp::wrap( 10000*av.major + 100*av.minor + av.patch ) ;

That one is good enough for me on almost all days. 

| > | With some imagination, I think we can achieve this, but I was wondering
| > | what the interface should be like. I was thinking maybe making it static
| > | member function templates of Vector<>, so that we would do for example:
| > |
| > | NumericVector x = NumericVector::create(
| > | 	_["x"] = 2.0,
| > | 	_["y"] = 1.0
| > | ) ;
| >
| > Again, why?  I would guess that the corpus of existing C++ code calling its
| > elements by name is pretty limited.  So why do we need or want to create
| > named vectors at the c++ level?  For returning to R, sure, but can't that be
| > had with less firepower?
| 
| For example ?

Just creating a vector of chars and assigning it just like we've done
before. No need for a new layer of classes. Just saying...
 
| > Don't want to be difficult here but maybe our time is spend more fruitfully
| > one layer up (eg returning to RProtoBuf)
| 
| Sure. be my guest. why don't you start a discussion on what features of 
| RProtoBuf you are talking about and how you are going to handle them ...

Touch'e.

But I still think we could let more things be driven by actual use.  Anyway,
I am not attempting to stand in your way. Trying to stop an oncoming train
with bare hands is rarely successful, so have at it if you feel you must...

Dirk

-- 
  Registration is open for the 2nd International conference R / Finance 2010
  See http://www.RinFinance.com for details, and see you in Chicago in April!


More information about the Rcpp-devel mailing list