This post originated from an RSS feed registered with Ruby Buzz
by Daniel Berger.
Original Post: Better Keyword Arguments
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
I took an immediate dislike to this proposal. The first problem I have with it is that you're forced to make a declaration about How Things Work in the method definition. The second problem I have is that I'll be forced to lookup the method definition in order to see which parameters allow keyword arguments and which don't. That, or we'll need a major change to rdoc.
Things went from bad to worse with the *rest and **keyword syntax. Oofda.
This makes my head want to explode. It's a complete break from current Ruby syntax, looks like complete hell, and is utterly untuitive. It's just overwrought.
The ideal solution is to allow users to use keyword parameters without having to do anything special whatsovever in the method definition, and allowing keyword parameters to be used for all variables, in addition to allowing positional parameters:
As for *rest parameters, the ideal situation is to eliminate **keys altogether (yuck) and keep the current behavior where *rest arguments come at the end of the method declaration. For keyword parameters slurped into a *rest variable, they are collected as a hash:
Clean. Sensical. No extra work in the method declaration. Keeps the current rules in effect with regards to *rest variables. None of that **keys nonsense. Even forces you to use good variable names for people reading the generated documentation who need to know what the valid parameters are.
Wouldn't that be awesome?
Now what if I told you that it's already in Sydney?