title: Variable scope in S3 generics
body: <p>I have the following snippet:</p>
  
  <pre><code>y &lt;- 1
  g &lt;- function(x) {
    y &lt;- 2
    UseMethod("g")
  }
  g.numeric &lt;- function(x) y
  g(10)
  # [1] 2
  </code></pre>
  
  <p>I do not understand, why it is possible to have access to <code>y</code> in <code>g.numeric &lt;- function(x) y</code>. To my understanding y's scope is just within the definition of the generic <code>(g &lt;- ...)</code>. Could anyone explain to me, how that is possible?</p>