Named arguments increase readability a lot

I can't speak specifically about veterans of Swift/ObjC, but requests for named parameters in Rust are certainly nothing new, and there's been loads of detailed discussion in the past. The best place to start is probably:

If the question here is "why haven't we done this yet?" then my personal impression is that the answer is a combination of:

  • options objects and using enums in place of bools/ints/etc are already good enough for many of the use cases, so the motivation is simply not as pressing as e.g. async/await or module system reform or NLL
  • typical named arguments proposals have very heavy overlap if not direct conflicts with other proposals, including:
    • optional arguments
    • type ascription, since : is the obvious sigil for both
    • structural records / anonymous structs, since they'd make options objects even more ergonomic, likely covering all of the motivation for named args
  • named/keyword arguments have subtle semver implications, which other languages have suffered from in practice, so even without the conflicting proposals there's some serious design work to do here
  • For the last few years the Rust project as a whole has been carrying an unhealthily large backlog of features that have achieved community consensus in an RFC, but have yet to be fully implemented and stabilized. Untangling the keyword/optional/named arguments mess simply isn't one of those features with an existing consensus; we need to focus our resources on shipping all the things we've already designed.
42 Likes