On Mon, Dec 16, 2013 at 9:12 PM, Gandalf Fladnag <lists / ruby-forum.com> wrote:
> Robert Klemme wrote in post #1130770:
>> On Mon, Dec 16, 2013 at 6:58 PM, Gandalf Fladnag <lists / ruby-forum.com>
>> wrote:
>>>>>> [2,3,4,5]
>>>>>> 1
>>>>
>>>> In other words: Gandalf, what you ask for is ambiguous.  The parser
>>>> cannot decide whether g(1,2) should give 1, [], 2 or 1, 2, 1.  There
>>>> is no automated way to decide this unless some priorities are given
>>>> with regard to args with * and those with default value.
>>>
>>> There is the following sensible rule: it should always be possible to
>>> assign to any parameter.
>>
>> How do you do that if there are less arguments than parameters?  It's
>> no use if it cannot be safely and automatically determined which
>> parameters should receive which values.
>
> I meant something different.
>
> Let's consider again
>   def f(x,*y,z=1)
>     p x,y,z
>   end
> If we decide that f(1,2,3) prints
> 1
> [2,3]
> 1
> then we're saying that y should capture anything starting from the
> second parameter. That makes it impossible to give a value to z and thus
> this should be avoided according to the rule I was talking about.

It *is* avoided because the syntax is illegal.

> Basically, if the arguments are more than one, z should always take the
> last argument.

Hence you introduce priorities - as I stated above.  I think that
makes things too complicated and thus error prone.  I assume that it
has not been done exactly because of this.

Cheers

robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/