mllg / checkmate

Fast and versatile argument checks
https://mllg.github.io/checkmate/
Other
261 stars 30 forks source link

qassert in RCPP #114

Open berndbischl opened 7 years ago

berndbischl commented 7 years ago

I am beginning to use cm to check args in my RCPP function code.

1) it is really great that this works, in principle.

2) IMHO the example in the vignette should be extended, or rather: there should be a concrete, longer example. One thing that might be confusing to some people is that you now have to work with SEXPs in your signature, i think, instead of letting RCPP already convert to the native C++ type. That would be clearly visible from a full example.

3) Matrices seem a bit less supported? Can I eg check for dims? or other stuff?

mllg commented 7 years ago

IMHO the example in the vignette should be extended, or rather: there should be a concrete, longer example. One thing that might be confusing to some people is that you now have to work with SEXPs in your signature, i think, instead of letting RCPP already convert to the native C++ type. That would be clearly visible from a full example.

There are cases where you need to do some type juggling on SEXPs before converting to a Rcpp representation, and this is where qassert can still be useful. Otherwise I probably would just stick to the auto-conversion done by the Rcpp wrappers and do the remaining checks (missings, finte values, etc.) with Rcpp-sugar.

Matrices seem a bit less supported? Can I eg check for dims? or other stuff?

qassert can only check for basic attributes, dimensions are not supported. You can still call checkmate from R just before .Call.