[Rcpp-devel] generalizing make_list

Romain Francois romain.francois at dbmail.com
Thu Mar 18 13:50:53 CET 2010


Le 18/03/10 13:37, Dirk Eddelbuettel a écrit :
>
> 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...

I will. Note that you still did not reply to the original question, 
which is what the name should be, and you are usually the one with 
opinions on these matters (e.g. you don't like make_list).

Romain

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/OIXN : raster images and RImageJ
|- http://tr.im/OcQe : Rcpp 0.7.7
`- http://tr.im/O1wO : highlight 0.1-5




More information about the Rcpp-devel mailing list