2 ms·
That blog post says that "Rust doesn’t have named parameters, and possibly never will". Could you clarify why that is the case? In my experience, named argument
by int_19h 3y ago
That blog post says that "Rust doesn’t have named parameters, and possibly never will". Could you clarify why that is the case? In my experience, named arguments in all but the simplest - i.e. unary and some binary - function calls give a massive boost to readability. And for Rust specifically, they would also provide an easy, unambiguous way to "overload" functions, similar to Swift (I'm putting "overload" in quotes here because it's not really overloading, as parameter names simply become part of the function name). So, why weren't they considered, or if they were considered, why were they rejected so emphatically that you don't anticipate them showing up even in the future?
- steveklabnik 3y agoPart of it is that it's not just named parameters: you should have a good story for default parameters too, and I think one or two others? Variadrics feels similar but separate. Oh, anonymous structs would allow you to emulate them while not adding the feature directly. Therefore, it ends up being a really huge thing, with lots of design space. This is combined with the fact that > they would also provide an easy, unambiguous way to "overload" functions Not everyone sees this as a good thing. Being slightly controversial, plus being really large, plus there being a lot of other things to do, would make me surprised if they ever land. Here's a link from eight years ago with a link to lots of other related proposals: https://internals.rust-lang.org/t/pre-rfc-named-arguments/3831 https://internals.rust-lang.org/t/pre-rfc-named-arguments/38...