title: R hangs when there are too many arguments in setMethod (or setGeneric)
body: <p>Basically, when there are many arguments in <code>setMethod</code> or (<code>setGeneric</code>) it works very slowly. </p>
  
  <p>Here is a basic example:</p>
  
  <pre><code>setClassUnion(name = "mNumeric", members = c("missing", "numeric"))
  setClass(Class = "classA", representation = representation(ID = "character"))
  
  setGeneric("foo", function(r, i, ..., m = 1, D = 1, U = 999, K = 0.005, 
                             E1 = -5, E2 = 5, E3 = 1, E4 = 1, E5 = 1, E6 = 1,
                             A1 = -5, A2 = 5, A3 = 1, A4 = 1, A5 = 1, A6 = 1)
                    {standardGeneric ("foo")})
  
  setMethod(f = "foo", 
    signature = c(r = "ANY", i = "classA", m = "mNumeric", D = "mNumeric", 
                  U = "mNumeric", K = "mNumeric", E1 = "mNumeric", E2 = "mNumeric",
                  E3 = "mNumeric", E4 = "mNumeric", E5 = "mNumeric", E6 = "mNumeric", 
                  A1 = "mNumeric", A2 = "mNumeric", A3 = "mNumeric", A4 = "mNumeric", 
                  A5 = "mNumeric", A6 = "mNumeric"),
    function(r, i, ..., m, D, U, K, E1, E2, E3, E4, E5, E6, A1, A2, A3, A4, A5, A6)
      {print("Function can made it here..")})
  
  #Program hangs after the following code. (at least five minutes)
  foo(r = 1, i = new("classA", ID = "ID1"))
  </code></pre>
  
  <p>I observe that this is not related to the class. You can put a <code>numeric</code> class into <code>r</code> and it will do the same. If I trim the number of arguments it will work.</p>
  
  <p>I suspect that it tries "<code>to find an inherited method for function ‘foo’ for signature ‘"numeric", "classA", "missing", ...</code>" and this causes R to hang. <a href="https://stackoverflow.com/questions/16386154/is-s4-method-dispatch-slow">HERE</a> is a good discussion of this topic. </p>
  
  <p>Because if I run same code with less parameters it works:</p>
  
  <pre><code>setGeneric("foo", function(r, i, ..., m = 1, D = 1, U = 999, K = 0.005, 
                             E1 = -5, E2 = 5, E3 = 1, E4 = 1)
            {standardGeneric ("foo")})
  
  setMethod(f = "foo", 
    signature = c(r = "ANY", i = "classA", m = "mNumeric", D = "mNumeric", 
                  U = "mNumeric", K = "mNumeric", E1 = "mNumeric", E2 = "mNumeric",
                  E3 = "mNumeric", E4 = "mNumeric"),
    function(r, i, ..., m, D, U, K, E1, E2, E3, E4)
    {print("Function can made it here..")})
  
  foo(r = 1, i = new("classA", ID = "ID1"))
  </code></pre>
  
  <p>Why this happens? Any ideas will be appreciated.</p>