title: Why does R ellipsis (...) match more arguments when using nested functions?
body: <p>I would like to understand why the <code>...</code> argument matches the <code>extra</code> argument when nesting <code>f()</code> within <code>g()</code>.</p>
  
  <p>Say that <code>f()</code> is this function:</p>
  
  <pre class="lang-r prettyprint-override"><code>f &lt;- function(..., extra = NULL) {
      . &lt;- list(...)
      print(.)
  }
  </code></pre>
  
  <p>The output is, as expected, what is contained in the <code>...</code> argument:</p>
  
  <pre class="lang-r prettyprint-override"><code>f("a", "b", "c", extra = "123")
  
  # [[1]]
  # [1] "a"
  
  # [[2]]
  # [1] "b"
  
  # [[3]]
  # [1] "c"
  </code></pre>
  
  <p>However, when using it within another function, say <code>g()</code>:</p>
  
  <pre class="lang-r prettyprint-override"><code>g &lt;- function(..., extra = NULL) {
      f(..., extra)
  }
  </code></pre>
  
  <p>The <code>...</code> also captures the <code>extra</code> argument:</p>
  
  <pre class="lang-r prettyprint-override"><code>g("a", "b", "c", extra = "123")
  
  # [[1]]
  # [1] "a"
  
  # [[2]]
  # [1] "b"
  
  # [[3]]
  # [1] "c"
  
  # [[4]]
  # [1] "123"
  </code></pre>
  
  <p>My question is twofold: (1) why is this the case and (2) how to correctly handle this?</p>