Daniel Berger wrote:
> Yukihiro Matsumoto wrote:
>> not legal since you don't have an argument with a name "foo"?
>> 
>> Have you changed your mind since the blog entry at
>> http://djberg96.livejournal.com/50162.html?  For you have written
>> 
>> 
>>>foo(1, 2, foo:4, bar:5) # a=1, b=2, c=[{'foo'=>4, 'bar'=>5}]
>>>foo(1, 2, 8, baz:5)     # a=1, b=2, c=[8, {'baz'=>5}]
>> 
>> 
>> in it.  foo:4 etc. seems like non-literal hash.
> 
> Oops - I didn't notice you had declared it "*c" instead of "c".  My blog 
> entry
> is the expected behavior.
> 
>> |>  args = [1, {:b=>2, foo=>5}]
>> |>  foo(*args)        # (a=1,b={:b=>2, foo=>5}) or (a=1,b=2,c=[{:foo=>5}])?
>> |
>> |a = 1, b = {:b=>2, foo=>5}, since you've passed a literal hash.
>> 
>> This means that you cannot accept
>> 
>>  (a) a keyword argument that is possibly accepted by the superclass's
>>      method, without knowing their names
> 
> I'm not sure I follow.  How would you know the keyword arguments without
> knowing their names?  Or are we getting into keyword discovery here?
> 
>>  (b) arbitrary keywords that can be passed to other methods
> 
> What do you mean by 'arbitrary keywords'?

I presume both this and the section before, Matz means
a situation like this:

  def actual_method(a, b, c, d)
    # ...
  end

  def delegator(*args, &block)
    actual_method *args, &block
  end

  delegator 1, 2, 3, d:4

The call is not really possible unless the keyword
'd' is automatically converted to a positional or
passed through in a hash or something like that.

The simple answer is that it is the responsibility
of the implementer of #delegator to map the call
so that no error is raised. This may not work in
cases where the whole of the dispatch is done
dynamically (although these may be quite rare).

>> Right? If so, (a) means you need to have exact argument information
>> about a superclass method, which may not be available for mix-in
>> modules;
> 
> I'm afraid I'm not following.
> 
> (b) means there's no way to convert keyword arguments to a
>> hash.
> 
> Are you talking internals, or by the user?
> 
> Well, anyway, I think this has all been gone over before.  I probably 
> should
> have just kept my mouth shut.
> 
> Dan


E

-- 
Posted via http://www.ruby-forum.com/.