On Oct 10, 2007, at 22:44 , Charles Oliver Nutter wrote:
> It seems like a number of methods have unexpected arities. For  
> example, Array#[]
>
> $ ruby -e "puts Array.method(:[]).arity; x = [1,2,3]; x[]"
> -1
>
> I've been running into a number of these. We have been trying to  
> get all methods and arities matching in JRuby, but these numbers  
> don't seem to make sense. Should they be corrected in Ruby?

The -1 arity exposes the argument checking implementation, which is  
done manually for -1 methods.  On the C side, the -1 and -2 arities  
tell ruby how to call the C function properly.  Adding the Ruby arity  
to them would require instrumenting every method, but non-stdlib  
extensions would still lie.

Is it a big deal?  Its easy to make a method that lies about its arity:

def liar(a, b, c, d, e, f, g, h)
   raise ArgumentError, "wrong number of arguments (0 for 1)"
end

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars