Call match.call() from C++ code
<p>I'm having trouble calling <code>match.call()</code> from a C++ function. In the example below, the <code>match_call()</code> C++ function fails at simply forwarding its arguments to <code>match.call()</code>. What am I missing?</p>

<pre><code>match_call &lt;-
  Rcpp::cppFunction(
    '
      SEXP match_call(SEXP definition, SEXP call) {
        Function m("match.call", R_BaseEnv);
        return m(definition, call);
      }
    ')

match.call(function(a = 1, b = 2){}, quote(fun(b = 4, 3)))
## fun(a = 3, b = 4)
match_call(function(a = 1, b = 2){}, quote(fun(b = 4, 3)))
## error: could not find function "fun"
</code></pre>

<p>As suggested by @nicola, adding a <code>quote()</code> helps:</p>

<pre><code>        return m(definition, Rf_lang2(R_QuoteSymbol, call));
</code></pre>

<p>This works, but doesn't explain the mechanisms.</p>