From: Brian Candler Date: 2008-11-13T18:44:53+09:00 Subject: [ruby-core:19915] Re: Proposal: Method#get_args On Thu, Nov 13, 2008 at 07:02:25AM +0900, Jim Weirich wrote: > And while I strongly disagree with the design decisions on caller/ > backtrace (there is a lot of useful information in the strings that can > only be retrieved via brittle parsing), the args arrays proposed here > don't require parsing so are more in line with the other two > suggestions. That does give me an idea. Since "?" is not legal in a variable name, then a very simple option could be def foo(a, b, c=123, d=nil, *e, &blk) => ["a", "b", "?c", "?d", "*e", "&blk"] define_method(:bar) { |a,(b,c)| } => ["a", ["b", "c"]] The tuple alternative might be slightly easier to manipulate: [[:a,:req],[:b,:req],[:c,:opt],[:d,:opt],[:e,:rest],[:blk,:block]] [[:a,:req],[[[:b,:req],[:c,:req]],:group]] but I don't think there's much in it. (And I do realise that ?c has a different meaning in-line, but it's easier to parse if the argument type discriminator is always the first character)