title: How to detect missing dot-dot-dot in generic function argument
body: <p>Suppose I have a function like</p>
  
  <pre><code>z &lt;- function(x, ...) {
    print(x)
  }
  </code></pre>
  
  <p>If <code>...</code> is missing, the function should do one thing; if <code>...</code> is specified, the function should do something else with it. In this case I can use <code>missing(...)</code> to detect if <code>..</code> is missing. But I don't find an elegant way to detect with generic methods like <code>[.Obj(x, ...)</code> where missing <code>...</code> is still a <code>pairlist(&lt;emptyname&gt;)</code> and <code>missing(...) = FALSE</code> even if I don't give values.</p>
  
  <p>Here are some experiments:</p>
  
  <pre><code>z &lt;- function(x, ...) {
    cat(missing(...))
  }
  
  Obj &lt;- function() {
    env &lt;- environment()
    class(env) &lt;- "Obj"
    env
  }
  
  `[.Obj` &lt;- function(x,...) {
    cat(missing(...),"\n")
  }
  </code></pre>
  
  <p>With the above code evaluate the following:</p>
  
  <pre><code>&gt; z()
  TRUE
  &gt; z(a=1)
  FALSE
  &gt; Obj()[]
  FALSE 
  NULL
  &gt; Obj()[a=1]
  FALSE 
  NULL
  </code></pre>
  
  <p>However, in debug mode for <code>Obj()[]</code> in RStudio, it is like</p>
  
  <pre><code>Browse[1]&gt; list(...)
  Error: argument is missing, with no default
  Browse[1]&gt; missing(...)
  [1] FALSE
  </code></pre>
  
  <p>Somehow the way that works for <code>z()</code> does not work for <code>Obj()[]</code>. Is there an elegant way with little overhead to detect whether <code>...</code> is missing for the <code>[.Obj(x, ...)</code> case which I actually encounter?</p>
  
  <p>See also: <a href="http://r.789695.n4.nabble.com/Arguments-passing-through-dot-dot-dot-lose-ability-to-check-for-missing-td4656455.html" rel="nofollow">http://r.789695.n4.nabble.com/Arguments-passing-through-dot-dot-dot-lose-ability-to-check-for-missing-td4656455.html</a></p>