Hi,

In message "Re: [ruby-core:41600] [ruby-trunk - Bug #5694] Proc#arity doesn't take optional arguments into account."
    on Mon, 12 Dec 2011 11:30:26 +0900, Marc-Andre Lafortune <ruby-core / marc-andre.ca> writes:

|Yukihiro Matsumoto wrote:
|> We are not going to add incompatible changes to trunk, ...
|
|Could you please explain to me what difference you see between an "incompatible change" and any "bug fix"?

Good point.  It's whether the change makes difference from intention
of the original designer.  I know it's a vague definition.  But too
strict rule did not run community well in the past.

|As I've tried to detail my evaluation criteria, if there is no sign of intent, I do not consider it an "incompatible change". Noone has shown any sign of intent with respect to the arity bug. What justification do you have to call this an "incompatible change"?

I agree we have at least one bug in arity.

    def Object.foo(a=42); end
    foo = Object.method(:foo).to_proc
    bar = ->(a=42){}
    foo.arity == bar.arity # => false

should be true.

Also, I think we need to update the documentation.  After defining
consistent "right" definition.

|We've had #arity return -n-1 whenever there are optional arguments or "rest" arguments for the past 11 years. I'm honestly still surprised I even have to convince anyone and that a discussion is needed. This is the big lesson I'll get from this; I will try not to assume that obvious bug fixes are obvious anymore.

Thank you for finding inconsistency.  Now we need to fix up the
desirable behavior.  First I thought to keep the original arity
behavior, but after investigating the behavior, both Method#arity and
Proc#arity have weird corner cases.

My idea for new behavior is:

 * arity ignores all optinal arguments
 * arity returns -n-1 if there's rest argument
 * where n is number of mandatory arguments

 * we might need to add arity_max that honors optinal arguments, or
   existing #parameter may be good enough.

Any opinion?

							matz.