[Rcpp-devel] (no subject)

Dirk Eddelbuettel edd at debian.org
Fri Nov 13 14:04:11 CET 2009


Hi Ott,

Replying to both your emails at once/

On 13 November 2009 at 10:38, Ott Toomet wrote:
| Dear Dirk (& possibly others)
| 
| I am modifying RcppParams for my needs (you remember our discussion
| yesterday).  Seems to be a quite easy task.  However, why do you require
| all the parameters to be named?  What about allowing non-named parameters
| and implementing access by position?  (This is what I do for my purpose,
| but I'd like to rely on something more stable than my own hacks).  I would
| be happy to provide some voluntary help here ;-) 

Access-by-name is how the rest of the package works. Consistency is good.

Access by position can have its advantages, but it can also be more
error-prone.  Changes, if any, should at least allow access by name, and for
parameter passing, require it. 

I would like to to see a strong rationale for changing the style of the
library, in particular if it is only for certain input types and not others.

On 13 November 2009 at 11:13, Ott Toomet wrote:
| OK, so it works for me now.  I changed RcppParams a little bit, so it can
| extract arbitrary list components (getValue member function) and it's
| components need not to be named ('named' member variable).  It is also easy
| to extract components by position. 

Ok, the way these things are often done is by patch against current
sources. Please work against the Subversion repository at R-Forge (which you
can check out anonymously), and provide a diff against these sources.  Please
also patch the help pages (man/RcppParams.Rd) and other files such as tests
etc (not applicable).  

| I would be happy to implement some of the stuff in a more polished way to
| the package but only if we can agree about what and how. 

Yes, let's start with simple and well-defined changes and let's see how that goes.

| Best,
| Ott
| 
| Below my modified class.
| 
| class RcppParams {
| public:
|     RcppParams(SEXP params);
|     void   		 checkNames(char *inputNames[], int len);
|     bool		 exists(std::string name);
|     double 		 getDoubleValue(std::string name);
|     int    		 getIntValue(std::string name);
|     std::string  getStringValue(std::string name);
|     bool   		 getBoolValue(std::string name);
|     RcppDate 	 getDateValue(std::string name);
|     RcppDatetime getDatetimeValue(std::string name);
|     SEXP         getValue(std::string name);
|     SEXP         getValue(int posn) { return VECTOR_ELT(_params,posn); };

Are you saying that your change is these two lines?  But what about
error-checking? 

What about my comments in earlier mail to you that you do not need 'get SEXP
from list' as you can simply pass more SEXP objects in the initial call from
R via .Call() ?  It is not too polite to simply ignore questions and move on.

Romain and I also had discussions about possibly adding a new internal SEXP
representation. RcppTemplate has one, Rserve has another.  If we do that than
this change would probably be a 'toSEXPtype' extractor.

|     int          size() { return Rf_length(_params); };
|     bool         isNamed() { return named; };

Who sets names?  A diff to src/RcppParams.h and src/RcppParams.cpp would be
easier to analyse.

Regards, Dirk


| 
| private:
|     bool named;
|     std::map<std::string, int> pmap;
|     SEXP _params;
| };

-- 
Three out of two people have difficulties with fractions.


More information about the Rcpp-devel mailing list