Skip to content
Prev 616 / 10988 Next

[Rcpp-devel] Yet Another Design Question

On Tue, Apr 13, 2010 at 1:14 AM, Romain Francois
<romain at r-enthusiasts.com> wrote:
For the time being I am thinking only of generating class definitions
for C++ and default constructors.  The problem with translating
methods from S4 to C++ is multiple dispatch in S4.  One of the big
advantages of S4 as a class system is multiple dispatch on methods,
which is possible because the methods exist outside the class
definition.  We use this extensively in the Matrix package in defining
methods for matrix multiplication and solutions of linear systems.
For both those situations the choice of the method should take into
account the classes of the first two arguments.  Consider the output
of

library(Matrix)
showMethods("%*%")
showMethods("solve")
showMethods("crossprod")
showMethods("tcrossprod")

Those would not translate readily to C++
I don't object to using that construction.  Because Rcpp is a
collection of templates I don't think this will add overhead in the
compiled code - it just adds a bit of work for the compiler.