Hi,

In message "Re: [ruby-core:19759] Proposal: Method#get_args"
    on Mon, 10 Nov 2008 07:46:51 +0900, "Yehuda Katz" <wycats / gmail.com> writes:

|I'd like to propose a way to introspect into the arguments of a method
|object. Merb uses this feature, which is already available via ParseTree in
|1.8.6, via compile-time in Rubinius, and via internal structures in JRuby.
|I'd like to formalize the API so it can be added to 1.9, which cannot use
|ParseTree.
|
|The API would return a tuple representing the arguments. The first element
|of the tuple is an array of the required and optional arguments. Required
|arguments are a single-element tuple containing a symbol representing the
|argument ([:foo]). Optional arguments with pure-literal defaults are
|represented as a two-element tuple containing a symbol representing the
|argument and the literal ([:foo, 1]). In the current implementations of this
|API in 1.8, JRuby and Rubinius, non-literal defaults return nil. Instead, we
|could create a constant that got returned (something like Method::OPTIONAL,
|[:foo, OPTIONAL]).

As I said in person at the conference place, I am positive about the
idea.  But it's too late for 1.9.1.  I wish you proposed a few month
earlier.  We have to wait for 1.9.2, of which release date I don't
know (or settle) yet.

I think we have to address some issues:

* the name.  In Ruby, unlike Java, we rarely use the verb get for
  method names.  We prefer foo to get_foo, when foo can be considered
  as an attribute.  But in this case, args instead of get_args sounds
  bit weird to me.

* there is name-less rest argument (a, b, *), which just ignores the
  rest arguments.  I think we have give some meaningful value for that
  case too.

* 1.9 added mandatory argument at the bottom of argument list (after
  rest argument *, just before block argument &).  We have to address
  this in the returning tuple.

							matz.