Why does method inheritance kill additional arguments? : <p>I want to set some flags in my generic (<em>before</em> calling <code>UseMethod()</code>, I know that much :)), and then use and/or update these flags in the methods.</p>

<p>Like so:</p>

<pre><code>g &lt;- function(x) {
  y &lt;- 10
  UseMethod("g")
}
g.default &lt;- function(x) {
  c(x = x, y = y)
}
g.a &lt;- function(x) {
  y &lt;- 5  # update y from generic here
  NextMethod()
}
</code></pre>

<p>This works when jumping directly to the default method:</p>

<pre><code>g(structure(.Data = 1, class = "c"))  # here y is never updated
# x  y 
# 1 10 
</code></pre>

<p>But when I go through <code>NextMethod()</code>, <code>y</code> mysteriously disappears:</p>

<pre><code>g(structure(.Data = 1, class = "a"))  # here y is updated, but cannot be found
# Error in g.default(structure(.Data = 1, class = "a")) : 
#  object 'y' not found
</code></pre>

<p>I <em>have</em> figured out how to fix this, by just passing around <code>y</code> a lot:</p>

<pre><code>f &lt;- function(x, ...) {
  y &lt;- 10
  UseMethod("f")
}
f.default &lt;- function(x, ..., y = 3) {
  c(x = x, y = y)
}
f.a &lt;- function(x, ...) {
  y &lt;- 5
  NextMethod(y = y)
}
</code></pre>

<p>which yields</p>

<pre><code>f(structure(.Data = 1, class = "c"))
# x y 
# 1 3 
f(structure(.Data = 1, class = "a"))
# x y 
# 1 5 
</code></pre>

<p>My question is: <strong><em>Why</em> does <code>NextMethod()</code> in the above <code>g().*</code>-example kill the additional <code>y</code> argument</strong>?</p>

<p>I thought the whole point of <code>UseMethod()</code> and <code>NextMethod()</code> was to pass on any and all objects from call to call, <em>without</em> having to manually pass them on:</p>

<blockquote>
  <p>NextMethod works by creating a special call frame for the next method. If no new arguments are supplied, the arguments will be the same in number, order and name as those to the current method but their values will be promises to evaluate their name in the current method and environment.</p>
  
  <ul>
  <li><a href="https://www.rdocumentation.org/packages/base/versions/3.4.3/topics/UseMethod" rel="noreferrer"><code>help("UseMethod")</code></a></li>
  </ul>
</blockquote>

<p>I'm particularly confused that <code>UseMethod()</code> does seem to pass on <code>y</code>, but <code>NextMethod()</code> doesn't. </p>
