News for hackers. Stuff that matters.
Re:Announcing Rust 1.19 by krisdol on Thursday July 20, 2017 @04:14PM (#14815890)
Maybe they'll get there with time, but with 50 different parameters (... for one function? really?) I'd say put most of them in some kind of an options object, which certainly can have defaults and also checks your values at compile-time.
Re:Announcing Rust 1.19 by steveklabnik on Thursday July 20, 2017 @04:16PM (#14815910)
Yes, the currently-considered-idiomatic solution here is the builder pattern.
Re:Announcing Rust 1.19 by static_noise on Thursday July 20, 2017 @04:26PM (#14815997)
Here

https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot...

I count about 40 plus more which are not listed.

You surely could first make a dictionary or structure and fill it with these arguments. But then "kwargs" are just that, a dictionary.

I find the interface of the plot function pretty straightforward. There are a lot of options but it's pretty clear what they do and when to use them. Most often you use only some of them - but often different combinations. Splitting this up into multiple helper objects that need to be constructed and filled beforehand would turn the default one-liner into a ten-liner which is not better.

Re:Announcing Rust 1.19 by steveklabnik on Thursday July 20, 2017 @04:31PM (#14816030)
> But then "kwargs" are just that, a dictionary.

Maybe Ruby on Rails is an exception, but while I used to be a fan of default/keyword arguments, especially in combination, seeing how they were used there made me very much not like them any more. It's impossible to tell what's going on.

Re:Announcing Rust 1.19 by coldtea on Thursday July 20, 2017 @07:40PM (#14817101)
How about how Smalltalk, Obj-C, Swift uses them?

It's very clear there...

Re:Announcing Rust 1.19 by eridius on Friday July 21, 2017 @01:41AM (#14818320)
FWIW, Obj-C doesn't have keyword arguments. It just has infix method names. But all arguments in an Obj-C method are required, and the order is significant.

Similarly, in Swift, the order of defaulted arguments is significant. So you wouldn't see anyone do something like that crazy matplotlib method in Swift, because remembering the order of all the arguments in that function is impractical.

Re:Announcing Rust 1.19 by Gankro on Thursday July 20, 2017 @09:20PM (#14817435)
Yeah when we do named args it will very likely be based on Swift, but a bit different due to backwards compat and the desire to integrate it into existing methods like Vec::from_raw_parts and ptr::copy.