Stan_model() questions

I’ve been trying to reverse engineer stan_model() for my own purposes, and I have a few questions.

  • In the call to cxxfunctionplus(), why is the signature argument blank?

  • Does the plugin only handle compiler flags that it detects from the user’s machine?

  • The call to cxxfunctionplus() takes a pretty crazy includes= argument called inc (which is constructed here). Constructing that arg calls to get_Rcpp_module_def_code(). That function looks like it’s writing an Rcpp module. Why do you need Rcpp modules if you’re using a cxxfunction() wrapper? I always thought those were two competing ways to run compiled code from within R.

  • In the call to cxxfunctionplus(), why is body = paste(" return Rcpp::wrap(\"", model_name, "\");", sep = '') Why is it so simple?

  • Is 100% of the code being compiled just passed in through includes=?

  • Why does cxxfunctionplus() take an argument called module_name=? Its documentation says extra args are passed through to the plugin, but I don’t see the plugin handling that at all.

Regarding (3), they are not competing, as evidenced by the examples in the Rcpp modules vignette:

Of the people working on Stan, the only people likely to know the answer here are @bgoodri and maybe @Jonah or @andrjohns.

Definitely a @bgoodri question!