3 ms·
"Named arguments" - what took you so long?! it always annoyed me that this is not always considered a standard language feature and added in from version 0.1 of
by nnq 14y ago
"Named arguments" - what took you so long?! it always annoyed me that this is not always considered a standard language feature and added in from version 0.1 of any language, no need to hack around it by passing dicts/hashes around ...Python got this right long time ago ...it always amazes me that people never seem to care about this
- Xylakant 14y agoThe standard solution (using splat and passing a hash) was close enough to work. It's not named arguments, and it certainly has its pitfalls, but it was close enough for most things. So nobody obviously thought it was important enough to change before now. There's a lot of languages that don't have named arguments so it's probably not that much of a deal either.
- nnq 14y ago...but the perceived philosophy of Ruby is along the lines of "developer joy above anyth else" (above speed, above code readability etc.) and this is a 100% developer joy feature and it's been ignored time and time again (probably because people are too busy building cool stuff to have time to bitch about this but still...)
- Xylakant 14y agoIt is. And the feature hasn't really been ignored. The hash-syntax was amended so that passing arguments as hashes can be made to look more like named arguments [1]. It's still not named arguments, but about as good as you can make it while still remaining somewhat backwards compatible. So yes, it took a long while but no, the pain was not very great. I never really missed that. [1] Voice-of-Evening:~ fgilcher$ irb 1.9.3p125 :001 > def foo(args) 1.9.3p125 :002?> puts args.inspect 1.9.3p125 :003?> end => nil 1.9.3p125 :004 > foo bar: "baz", foo: "bar" {:bar=>"baz", :foo=>"bar"} => nil 1.9.3p125 :005 >