title: passing unevaluated expressions to C/C++
body: <p>I'd like to pass a variable number of arguments from a function to C/C++, but would like to leave the arguments unevaluated and at the same time don't want to do any computations in R (aside from calling the C/C++ function), i.e. I don't want to call <code>substitute</code> in my R function. One option for this that I thought I could use is <code>.External</code> and doing smth like this:</p>
  
  <pre><code>R_fn = function(...) .External("cpp_fn", ...)
  
  ...
  # and in C code:
  SEXP cpp_fn (SEXP arglist) {
  }
  </code></pre>
  
  <p>However <code>.External</code> is evaluating arguments in <code>...</code>, so if I try something like</p>
  
  <pre><code>rm(x, y) # just making sure these don't exist
  
  R_fn(x*y)
  </code></pre>
  
  <p>I get an error because R is trying to evaluate <code>x*y</code> <em>before</em> sending it to the function.</p>
  
  <p>To contrast, the following works in R:</p>
  
  <pre><code>f = function(...) g(...)
  g = function(x, ...) print(substitute(x))
  
  f(x*y*z)
  # x * y * z
  </code></pre>
  
  <p>What other options do I have? Clearly it's possible to do as R itself does it for a number of functions, e.g. <code>substitute</code> itself, but I don't understand how to do it. I added the <code>rcpp</code> tag because my eventual usage of this is going to be in <code>Rcpp</code>.</p>