On Sun, Nov 23, 2008 at 04:00, David A. Black <dblack / rubypal.com> wrote:
> Hi --
>
> In this code:
>
>>> def m(a,b="b",c="c",d); p [a,b,c,d]; end
>
> => nil
>>>
>>> m(1,2,3)
>
> [1, 2, "c", 3]
> => [1, 2, "c", 3]
>
> I would expect [1, 3, "c", 2], because I would expect d (a required
> argument) to be handled before b (an optional argument).
>
> I know it's almost unthinkable that one would use this method
> signature, but I'd still like to understand the reasoning fully. I
> thought the idea was: handle the required arguments first, but it
> seems to be: move from left to right, looking ahead at every point to
> see whether there are enough arguments left and, at that point, give
> the right-hand required arguments priority. Is that right?

 Arguments should never be reordered (ignoring named argument
possibilities). That would lead to even more insanity I think. It does
mean that argument layout is a slightly complicated process now but
knowing the arguments will keep an order should at least help
guarantee that left and right arguments are satisfied properly.

Brian.