[Rcpp-commits] r1365 - in pkg/Rcpp/inst/doc: . snippets

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat May 29 14:22:15 CEST 2010


Author: romain
Date: 2010-05-29 14:22:14 +0200 (Sat, 29 May 2010)
New Revision: 1365

Added:
   pkg/Rcpp/inst/doc/snippets/S4dispatch.R
Modified:
   pkg/Rcpp/inst/doc/Rcpp-modules.Rnw
Log:
a word about S4 dispatch

Modified: pkg/Rcpp/inst/doc/Rcpp-modules.Rnw
===================================================================
--- pkg/Rcpp/inst/doc/Rcpp-modules.Rnw	2010-05-29 11:55:38 UTC (rev 1364)
+++ pkg/Rcpp/inst/doc/Rcpp-modules.Rnw	2010-05-29 12:22:14 UTC (rev 1365)
@@ -235,6 +235,15 @@
 
 \InputIfFileExists{snippets/modulestdvec}{}{}
 
+\subsubsection{S4 dispatch}
+
+When a C++ class is exposed by the \texttt{class\_} template, 
+a new S4 class is registered as well. This allows implementation of R-level 
+(S4) dispatch. For example, one might implement the \texttt{show}
+method for C++ \texttt{World} objects: 
+
+\InputIfFileExists{snippets/S4dispatch}{}{}
+
 \section{Future extensions}
 
 \texttt{Boost.Python} has many more features that we would like to port 

Added: pkg/Rcpp/inst/doc/snippets/S4dispatch.R
===================================================================
--- pkg/Rcpp/inst/doc/snippets/S4dispatch.R	                        (rev 0)
+++ pkg/Rcpp/inst/doc/snippets/S4dispatch.R	2010-05-29 12:22:14 UTC (rev 1365)
@@ -0,0 +1,4 @@
+setMethod( "show", "World", function(object){
+	msg <- paste( "World object with message : ", object$greet() )
+	writeLines( msg )
+} )



More information about the Rcpp-commits mailing list