yihui/knitr — pull request #427 by jjallaire (2012-11-27 00:24:05+00:00)
Title: uniform syntax for Rcpp code chunks

Eliminate ambiguity caused by supporting multiple conventions for embedding Rcpp code. This has a number of benefits:

(1) A common problem is to forget to adorn a function with // [[Rcpp::export]]. Unfortunately with the implicit mode switching we now have this unexpectedly "faults" the user into the cppFunction invocation style.

(2) Users will commonly need to do more than cppFunction offers (e.g. define multiple functions, define constants, define helper classes, etc.) so getting them used to sourceCpp up front will help them in the long run.

(3) Code chunks formatted for sourceCpp can be copied and pasted unmodified into a C++ file whereas code chunks formatted for cppFunction need the extra scaffolding added.

I'll send a pull request to update the knitr-examples document as well.