Thanks for the translation!

I've got a question about the proposal that will help me understand how it would be implemented.

Given a method:

def foo(name, age)
 p [name, age]
end

And then code that calls this method:

arg = { :name => "Evan", :age => 32 }
foo(arg)

Would this print out ["Evan", 32]?

If so, this seems like a very big change that a lot of code written against 1.9 will not work with.

Also, the example code in the proposal uses a form to call foo like this:foo(name: "Evan", age: 32)

This reuses the 1.8/1.9 behavior of the implicit hash parameter. Does this mean that the implementation creates a hash on the caller side, which is then pulled apart by the called method? If so, these seems just like my first example, and would end up breaking a lot of code.


Because 1.9 introduces the new hash syntax, which programmers have begun using with the implicit hash parameter, I don't think that the syntax cane used again for keyword arguments without introducing an incompatible change.

So, I'd like to suggest an alternative to this which uses a different (and thusly unambiguous) syntax:

foo(name="Evan", age=32)

I know that this is valid ruby code in 1.9, but it is extremely rare, much much more rare than the implicit hash parameter. Thusly it is safer andill not break 1.9 code.

This form also allows for an implementation of keyword parameters that don't require creating a Hash object, which makes the code faster and more useful.

If a truly new syntax must be introduced to be 100% backward compatible, I'd suggest:

foo(name := "Evan", age := 32)

:= is already known in computing as a bind operator, and thus it is suited well to this task.

Thank you for considering my proposal.

 - Evan

--  
Evan Phoenix // evan / phx.io


On Monday, October 17, 2011 at 9:08 PM, Yukihiro Matsumoto wrote:

> Hi,
>  
> I should have posted in English at first.
> Thank you guys for translation.
>  
>  matz.
>  
> In message "Re: [ruby-core:40191] Re: [Ruby 2.0 - Feature #5454] keyword arguments"
>  on Tue, 18 Oct 2011 11:56:29 +0900, Yutaka Hara <yutaka.hara / gmail.com (mailto:yutaka.hara / gmail.com)> writes:
> |
> |Hi,
> |
> |2011088:13 Evan Phoenix <evan / phx.io (mailto:evan / phx.io)>:
> |> This looks very interesting! Would someone be willing to translate to english? I've only got a vague idea of what is being discussed.
> |>
> |I and NaHi translated the mails.
> |
> |http://ruby-dev.info/posts/44602
> |
> |--
> |yhara (Yutaka HARA)