From: Yehuda Katz Date: 2008-11-14T18:32:58+09:00 Subject: [ruby-core:19934] Re: {Proc,Method}#parameters (Re: Proposal: Method#get_args) We need the defaults to handle out-of-order defaults: def action(bar=1, baz=2); end Where we get {baz => 5} inbound. Sent from my iPhone On Nov 14, 2008, at 3:47 AM, Brian Candler wrote: > On Fri, Nov 14, 2008 at 03:30:44PM +0900, Charles Oliver Nutter wrote: >> The original proposal also asked for literal defaults to be present. > > True - but it's not clear if, or how, the literal defaults are used > in merb. > > Since "=" is not a valid character in a local variable, you could > have a > string-based API which accommodates defaults: > > def action(a, b, c=123, d="hello #{c}", *e) > > => ["a", "b", "c=123", "d=\"hello #{c}\"", "e=*"] > > But if this information is more expensive to collect and to split > out, and > doesn't have a defined purpose, then I think it should be excluded. > > I don't think anyone's proposing this is an interface to be used by > rdoc or > other tools which need a full parse. In Merb's case, it's so that an > incoming parameters hash of > > {:a => "foo", :b => "bar", :x => "ignoreme"} > > can be passed to the action() method in the correct positions. It's a > poor-man's named arguments. >