From: Daniel Brockman Date: 2005-07-20T00:37:16+09:00 Subject: Re: [RCR] nil for unassigned keys Hi Pit, Thank you for your comments. >> This would also reasonably mean that mixing optional and >> mandatory arguments would become allowed: >> >> def bar(a, b=nil, c, d=nil, e) ... end >> >> bar 1 # ArgumentError >> bar 1, 2 # ArgumentError >> bar 1, 2, 3 # a=1, b=nil, c=2, d=nil, e=3 >> bar 1, 2, 3, 4 # a=1, b=2, c=3, d=nil, e=4 >> bar 1, 2, 3, 4, 5 # a=1, b=2, c=3, d=4, e=5 > > I don't like this. It is hard to see which value is put > into which parameter. Picking some arguments from the left > and from the right and stuffing the rest in the splatted > parameter is easier to grasp, at least for me. Then what about this? def baz(a, b=nil, c) ... end Isn't that just as easy to grasp as this? def baz(a, *b, c) ... end > I think the chances to get the RCR accepted are higher if > you drop this feature. You may be right. But I think restricting this to “only if there's a splat argument somewhere!” is pretty arbitrary. If you wanted the semantics of this, def baz(a, b=nil, c) ... end you'd have to write it like this, def baz(a, *dummy, b=nil, c) dummy.empty? or raise ArgumentError ... end which seems pretty annoying-for-no-reason. -- Daniel Brockman So really, we all have to ask ourselves: Am I waiting for RMS to do this? --TTN.