[Rcpp-devel] Vector<>::create
Romain Francois
romain at r-enthusiasts.com
Fri Mar 19 14:01:30 CET 2010
Hello,
I've commited Vector<>::create methods to support creation of any kind
of vectors with named or unnamed objects. examples:
// creating an unamed integer vector
IntegerVector::create( 10, 20 ) ;
// creating a named character vector
CharacterVector::create( _["foo"] = "bar", _["bar"] = "foo" ) ;
// creating a named list
List::create( _["foo"] = 10, _["bar"] = true ) ;
The syntax :
_[.] = .
can be replaced by this for people who don't like _ :
Argument( . ) = .
so for example :
List::create( Argument("foo") = 10, Argument("bar") = true ) ;
I could not use Named as it is now because it wraps the object too early
and so would only work for lists (which contains SEXP) and would not
work for e.g. integer vectors.
Here the rhs of Argument::operator= is kept as a reference until it is
effectively stored in the object, so Argument::operator= makes an object
of the template class traits::named_object which create knows how to
deal with, but the key is that named_object does not wrap but only
contains reference.
The new question is : should "Argument" be called something else ?
Should I rework all others clients of Named so that they use Argument
instead (in that case I would then call it Named).
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